Parallax scrolling - one class, multiple divs
How do I make an parallax scrolling - one class, multiple divs?
What is a parallax scrolling - one class, multiple divs? How do you make a parallax scrolling - one class, multiple divs? This script and codes were developed by Kevin on 04 September 2022, Sunday.
Parallax scrolling - one class, multiple divs - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Parallax scrolling - one class, multiple divs</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="solid">Hello</div>
<div class="parallax">
</div>
<div class="solid">Hello</div>
<div class="parallax"></div>
<div class="solid">Hello again</div>
<div class="parallax"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Parallax scrolling - one class, multiple divs - Script Codes CSS Codes
.parallax { padding: 25vh 0; background: url(//unsplash.it/800/800); background-size: cover;
}
.solid { padding: 25vh 0; background: steelblue; text-align: center; font-size: 6rem; color: white;
}
Parallax scrolling - one class, multiple divs - Script Codes JS Codes
$(window).scroll(function(e) { parallax();
})
function parallax() { var scroll = $(window).scrollTop(); var screenHeight = $(window).height(); $('.parallax').each(function() { var offset = $(this).offset().top; var distanceFromBottom = offset - scroll - screenHeight if (offset > screenHeight && offset) { $(this).css('background-position', 'center ' + (( distanceFromBottom ) * 0.5) +'px'); } else { $(this).css('background-position', 'center ' + (( -scroll ) * 0.5) + 'px'); } })
}
![Parallax scrolling - one class, multiple divs - Script Codes](http://shots.codepen.io/kevinpowell/pen/YVOLGz-512.jpg)
Developer | Kevin |
Username | kevinpowell |
Uploaded | September 04, 2022 |
Rating | 3 |
Size | 2,192 Kb |
Views | 30,360 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Flexbox - Flexbox Container Properties | 1,976 Kb |
A look at some CSS units | 2,585 Kb |
Anchors with smooth scrolling | 2,641 Kb |
Awesome Portfolio demo | 3,635 Kb |
Nav bar with fun hover effect | 1,867 Kb |
CSS outlines | 1,634 Kb |
Flexbox - Flexbox Basic Layout - start | 3,352 Kb |
Parallax only on large screens | 1,956 Kb |
Some fun button effects | 3,839 Kb |
Very simple jQuery dropdown navigation | 1,973 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Another brick in the wall | Fivera | 1,955 Kb |
Pericles mi loro... | Judag | 4,125 Kb |
Growing Root - Scroll control - CANVAS | Cjonasw | 2,342 Kb |
Acorrdian 2016 | Milanodituti | 3,720 Kb |
Filtering with shuffle.js | Deyand | 2,712 Kb |
Portfolio Page | HuffmanJ25 | 5,240 Kb |
Sass Get Function | Lukewatts | 2,155 Kb |
Importable Clearfix | Corysimmons | 1,411 Kb |
Blank Starter | Mhartington | 2,171 Kb |
Website Concept | Sagoza | 3,104 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!