This is one of the interesting concept to set the different scroll speed for different div. When you scroll each of the div moves based on the scroll speed you mentioned. For that you should include the JQuery file in the programs. The following code used to set the scroll speed each of the div.
<div class="box" data-scroll-speed="3">CSS</div>
<div class="box" data-scroll-speed="7">JAVASCRIPT</div>
<div class="box" data-scroll-speed="4">JQUERY</div>
I hope this topic will useful to you. Here we have the full code and also available the demo link of this program. Please check out the demo link for set the different scroll speed for each div. This types of concept is very useful somewhere in the programs.
How to set Different Scroll time for each div :
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>jQuery different scroll speeds</title>
<style>
body {
font-family: arial, sans-serif;
}
.content {
height: 9000px;
}
.wrapper {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-moz-box-pack: center;
box-pack: center;
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
-ms-flex-pack: center;
-webkit-box-align: center;
-moz-box-align: center;
box-align: center;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
-ms-flex-align: center;
height: 100vh;
width: 100%;
position: fixed;
top: 0px;
left: 0px;
}
.box {
-webkit-box-flex: none;
-moz-box-flex: none;
box-flex: none;
-webkit-flex: none;
-moz-flex: none;
-ms-flex: none;
flex: none;
height: 150px;
width: 190px;
line-height: 150px;
text-align: center;
font-size: 25px;
color: #fff;
background: #ff8330;
margin:25px;
}
.box:nth-of-type(2) {
background: #E01B5D;
}
.box:nth-of-type(3) {
background: #179292;
}
.box:nth-of-type(4) {
background: #699817;
}
</style>
</head>
<body>
<div class="content">
<div class="wrapper">
<div class="box" data-scroll-speed="5">HTML</div>
<div class="box" data-scroll-speed="3">CSS</div>
<div class="box" data-scroll-speed="7">JAVASCRIPT</div>
<div class="box" data-scroll-speed="4">JQUERY</div>
</div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
<html >
<head>
<meta charset="UTF-8">
<title>jQuery different scroll speeds</title>
<style>
body {
font-family: arial, sans-serif;
}
.content {
height: 9000px;
}
.wrapper {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-moz-box-pack: center;
box-pack: center;
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
-ms-flex-pack: center;
-webkit-box-align: center;
-moz-box-align: center;
box-align: center;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
-ms-flex-align: center;
height: 100vh;
width: 100%;
position: fixed;
top: 0px;
left: 0px;
}
.box {
-webkit-box-flex: none;
-moz-box-flex: none;
box-flex: none;
-webkit-flex: none;
-moz-flex: none;
-ms-flex: none;
flex: none;
height: 150px;
width: 190px;
line-height: 150px;
text-align: center;
font-size: 25px;
color: #fff;
background: #ff8330;
margin:25px;
}
.box:nth-of-type(2) {
background: #E01B5D;
}
.box:nth-of-type(3) {
background: #179292;
}
.box:nth-of-type(4) {
background: #699817;
}
</style>
</head>
<body>
<div class="content">
<div class="wrapper">
<div class="box" data-scroll-speed="5">HTML</div>
<div class="box" data-scroll-speed="3">CSS</div>
<div class="box" data-scroll-speed="7">JAVASCRIPT</div>
<div class="box" data-scroll-speed="4">JQUERY</div>
</div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
0 Comments