Basic parallax
How do I make an basic parallax?
What is a basic parallax? How do you make a basic parallax? This script and codes were developed by SNÖGRAFX on 26 August 2022, Friday.
Basic parallax - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Basic parallax</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <section id="home" data-type="background" data-speed="2" class="pages"> <article>Jupiter</article>
</section>
<section id="about" data-type="background" data-speed="10" class="pages"> <article>Saturn</article>
</section> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Basic parallax - Script Codes CSS Codes
body { margin: 0; font-size: 3em; color: white;
}
#home { background: url('http://upload.wikimedia.org/wikipedia/commons/5/5a/Jupiter_by_Cassini-Huygens.jpg') 50% 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative;
}
#home article { height: 458px; position: absolute; text-align: center; top: 150px; width: 100%;
}
#about { background: url('http://upload.wikimedia.org/wikipedia/commons/2/25/Saturn_PIA06077.jpg') 50% 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8);
}
#about article { height: 458px; position: absolute; text-align: center; top: 150px; width: 100%;
}
Basic parallax - Script Codes JS Codes
$(document).ready(function(){ // Cache the Window object $window = $(window); $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // assigning the object $(window).scroll(function() { // Scroll the background at var speed // the yPos is a negative value because we're scrolling it UP! var yPos = -($window.scrollTop() / $bgobj.data('speed')); // Put together our final background position var coords = '50% '+ yPos + 'px'; // Move the background $bgobj.css({ backgroundPosition: coords }); }); // window scroll Ends });
});
document.createElement("article");
document.createElement("section");
Developer | SNÖGRAFX |
Username | snografx |
Uploaded | August 26, 2022 |
Rating | 3 |
Size | 2,269 Kb |
Views | 38,456 |
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 |
Clickable back element | 1,517 Kb |
Mondrian Flexbox | 2,229 Kb |
CityPlanner fallback | 4,228 Kb |
CSS Close button | 2,309 Kb |
CSS X | 2,024 Kb |
Huzzo spinner | 1,748 Kb |
CityPlanner Logo Loading Animation 2017 | 2,589 Kb |
Norkart CityPlanner ribbon logo | 1,957 Kb |
Hide on inactivity | 2,082 Kb |
Google-style CSS options button | 2,293 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 |
Iron Man SVG Loading Animation | Andythayer | 3,069 Kb |
Wikipedia viewer | Chpecson | 2,865 Kb |
Elephants Full screen site | Orrinward | 3,981 Kb |
Layout 11 | Altynai | 1,690 Kb |
A Pen by Alex Bergin | Abergin | 3,347 Kb |
RWD Conversion Practice | Jxqr97 | 2,743 Kb |
Drop Cap | Gsaiki | 1,571 Kb |
GLSL Hills | Ykob | 6,991 Kb |
Simple jQuery Slider | Jurbank | 2,874 Kb |
Experiment - SCSS SVG Background Image with Variables | See8ch | 3,270 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!