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'); } })
}
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 |
Setting label widths | 1,556 Kb |
Mobile nav v2 | 2,892 Kb |
Some fun button effects | 3,839 Kb |
CSS blending modes test | 2,452 Kb |
CSS Grid Area demo | 3,928 Kb |
CSS Grid - Using line names | 2,676 Kb |
Anchors with smooth scrolling | 2,641 Kb |
Flexbox - Flexbox Basic Layout - start | 3,352 Kb |
Simple Clearfix | 1,508 Kb |
Div button vs link button | 1,514 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 |
SlideDown FixedMenu | Mp_graphic | 5,602 Kb |
Hover Animation from UNIQLO | Insprd | 3,772 Kb |
Buttons with style | Chbymnky | 2,082 Kb |
Custom Select Element | Agrayson | 3,616 Kb |
Three js | Paulq | 2,353 Kb |
Simple Linear Regression with Editable Table | Melatonind | 3,264 Kb |
Starfield using KineticJS | Asp | 3,512 Kb |
Weather Icons | Gtalin | 2,519 Kb |
BabyStore | Pablo-Ai | 3,807 Kb |
Toggle menu | Seyedi | 2,279 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!