Parallax scrolling - one class, multiple divs

Developer
Size
2,192 Kb
Views
30,360

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 Previews

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
Parallax scrolling - one class, multiple divs - Script Codes
Home Page Home
Developer Kevin
Username kevinpowell
Uploaded September 04, 2022
Rating 3
Size 2,192 Kb
Views 30,360
Do you need developer help for Parallax scrolling - one class, multiple divs?

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!

Kevin (kevinpowell) Script Codes
Create amazing captions with AI!

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!