Newsletter
Liste des sujets

[JS]probleme d'autoscrolling

extracasemoney
extracasemoney
Niveau 5
01 décembre 2018 à 17:19:32

j'ai un petit soucis.
J'ai crée une page vite fait, donc mon body contient 3 DIV. Chaque div à un effet de parallax et s'etend sur 100% du viewport. Maintenant, j'aimerais pouvoir gerer un autoscrolling qui permettrait de passer proprement d'une div a une autre (si possible sans jquery)

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<style>
		
		body{
			margin:0;
			padding:0;

		}

		#box1{
			height:100vh;
			width:100%;
			background-image: url(holiday.jpg);
			
			background-size:cover;
			background-attachment:fixed;
			display:table;
			position:relative;
			

			
		}

	
		#box2{
			height:100vh;
			width:100%;
			background-color:black;
			background-size:cover;
			background-attachment:fixed;
			display:table;
		
		}

		#box3{
			height:100vh;
			width:100%;
			background-image: url(sapin.jpg);
			background-size:cover;
			background-attachment:fixed;
			display:table;
		
		}

		h1{
			font-family:arial black;
			font-size:50px;
			color:white;
			margin:0px;
			text-align:center;
			display:table-cell;
			vertical-align:middle;
		   }

		
	</style>
</head>
<body>
	<div id="box1">
		<h1><a href='#'>fdfds</a></h1>
	</div>
	<div id="box2">
		<h1><a href="#">titre</a></h1>
	</div>
	<div id="box3">
		<h1>titre2</h1>
	</div>
	<script>
		var elmt = document.getElementsByTagName('a')[0];
		elmt.addEventListener('click',scrolling);

		function scrolling(){
			window.scrollTo(0,500);
		}
	</script>
</body>
</html>
Message édité le 01 décembre 2018 à 17:20:13 par extracasemoney
Sous forums
  • Aide à l'achat Mac
  • Macintosh
  • Création de Jeux
  • Programmation
  • Création de sites web
  • Linux
  • Internet
  • Steam Deck
  • Hardware
La vidéo du moment