Parallax Backgrounds
How do I make an parallax backgrounds?
What is a parallax backgrounds? How do you make a parallax backgrounds? This script and codes were developed by Andy Vanee on 21 September 2022, Wednesday.
Parallax Backgrounds - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Parallax Backgrounds</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="bg bg-normal"> <p> normal background </p>
</div>
<div class="bg bg-slow"> <div class="bg-slow-img"></div> <p> slow scrolling background </p>
</div>
<div class="bg bg-parallax"> <p> fast scrolling background </p> <div class="bg-parallax-img"></div>
</div>
<div class="bg bg-normal attachment-fixed"> <p> normal background attachment-fixed </p>
</div>
<div class="bg bg-scaling"> <p> scaling background </p> <div class="bg-parallax-scale"></div>
</div>
<div class="bg bg-normal"> <p> normal background... cleanse the palette </p>
</div>
<div class="bg bg-panning"> <p> panning background </p> <div class="bg-parallax-pan"></div>
</div>
<div class="colophon"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Parallax Backgrounds - Script Codes CSS Codes
.bg { width: 100%; height: 90vh; overflow: hidden; box-shadow: 0px 0px 60px rgba(0, 0, 0, 0.9); position: relative;
}
.bg p { position: absolute; z-index: 10; top: 20%; left: 20%; width: 42em; max-width: 60%; color: #777; font-size: 1.6em; background-color: rgba(255, 255, 255, 0.7); padding: 0.5em 1em;
}
.bg-normal { background-image: url(https://s169923.gridserver.com/images/fjord.jpg); background-position: center; background-size: cover;
}
.attachment-fixed { background-attachment: fixed;
}
.bg-slow-img { position: absolute; width: 100%; height: 140%; top: -20%; background-image: url(https://s169923.gridserver.com/images/norwaydock.jpg); background-position: center; background-size: auto 100%; background-repeat: no-repeat;
}
.bg-parallax-img { position: relative; width: 100%; height: 160%; transform: translateY(0%); background-image: url(https://s169923.gridserver.com/images/norwaytunnel.jpg); background-position: center; background-size: cover;
}
.bg-parallax-scale { position: relative; width: 100%; height: 100%; transform: scale(1); background-image: url(https://s169923.gridserver.com/images/thecanal.jpg); background-position: center center;
}
.bg-parallax-pan { position: relative; width: 140%; height: 140%; transform: translateX(0); background-image: url(https://s169923.gridserver.com/images/icelandlatte.jpg); background-size: 140%;
}
.colophon { height: 120vh;
}
Parallax Backgrounds - Script Codes JS Codes
'use strict';
//
// $(elem).progress(callback)
//
// calls the callback with a value between 0 and 1 based on the current
// position of the element within the viewport
// 0 when the top of the element reaches the bottom of the viewport
// 1 when the bottom of the element reaches the top of the viewport
//
$.fn.progress = function (cb) { var $me = $(this); var $win = $(window); var currentProgress = 0; $win.on('scroll', function () { var winHeight = $win.height(); var myHeight = $me.height(); var winTop = $win.scrollTop(); var winBottom = winTop + $win.height(); var myTop = $me.position().top; var myBottom = myTop + myHeight; if (winBottom < myTop) currentProgress = 0; // before if (myBottom < winTop) currentProgress = 1; // after var animatedHeight = myHeight + winHeight; var prog = 1 - (myBottom - winTop) / animatedHeight; currentProgress = Math.round(prog * 1000) / 1000; }); var $updater = function $updater() { if (currentProgress > 0 && currentProgress < 1) { cb(currentProgress); } requestAnimationFrame($updater); }; requestAnimationFrame($updater);
};
$('.bg-slow').progress(function (i) { var t = i * 20 - 10; $('.bg-slow-img').css('transform', 'translateY(' + t + '%)');
});
$('.bg-parallax').progress(function (i) { var t = 0 - i * 30; $('.bg-parallax-img').css('transform', 'translateY(' + t + '%)');
});
$('.bg-scaling').progress(function (i) { var scale_amount = 1 + i * 0.5; $('.bg-parallax-scale').css('transform', 'scale(' + scale_amount + ')');
});
$('.bg-panning').progress(function (i) { var pan_amount = 0 - i * 20; $('.bg-parallax-pan').css('transform', 'translateX(' + pan_amount + '%)');
});
Developer | Andy Vanee |
Username | andyvanee |
Uploaded | September 21, 2022 |
Rating | 3 |
Size | 4,281 Kb |
Views | 18,216 |
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 |
Transform iFrame | 2,544 Kb |
Historical Data | 6,472 Kb |
More Perspective | 3,293 Kb |
Generic Stock | 6,058 Kb |
Harmoniclock-16 | 3,278 Kb |
Some perspective 2 | 4,282 Kb |
Responsive Banner with VW | 1,688 Kb |
Css bullets | 1,618 Kb |
Harmoniclock Spiro | 2,799 Kb |
Ambient Animation | 4,186 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 |
Portfolio page | Bhavya_j | 2,804 Kb |
Expert Help | SinceSidSlid | 4,064 Kb |
The Fly | GianlucaGuarini | 3,405 Kb |
Video mute | Leon9208 | 2,131 Kb |
CSS only simple parallax scroll | Stanssongs | 3,708 Kb |
Hovers with popups | Zacharyolson | 2,380 Kb |
Realistic Buttons | Stoypenny | 2,248 Kb |
CSS Variables | Jdsteinbach | 4,759 Kb |
Drag in vanilla js using dotval math instead of translate | Paulq | 2,662 Kb |
Very Simple Slider | Doodlemarks | 2,682 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!