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 |
Smooth Scrolling with jQuery | 3,471 Kb |
Awesome Portfolio demo | 3,635 Kb |
Anchors with smooth scrolling | 2,641 Kb |
Simple Jumbotron with BG image | 1,946 Kb |
Some fun button effects | 3,839 Kb |
Bootstrap grid basics | 1,559 Kb |
Flexbox - Flexbox Basic Layout | 3,205 Kb |
Mobile nav | 2,771 Kb |
A Pen by Kevin | 2,231 Kb |
CSS Grid Area demo - the start | 2,847 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 |
Text Looping Transition | Agelber | 5,619 Kb |
Three js | Paulq | 2,353 Kb |
TimelineMax Circular loader | Nicolund | 2,649 Kb |
STIKHOI | Denmch | 7,122 Kb |
Clock with full screen background | Owebboy | 2,415 Kb |
Classy Blockquote Styling | Andrewwright | 3,212 Kb |
Plotting Points with D3.js | Laurakelly | 31,996 Kb |
Blog Concept 2 | JGallardo | 2,994 Kb |
Minimal Material Design Form Input | Koenigsegg1 | 3,076 Kb |
React Recipe Box | Krokodill | 5,347 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!