Parallax-ish Sliding Content
How do I make an parallax-ish sliding content?
On scroll, the current content (hero-style) slides off of the top of the "stack," but the height is decreased as well, so that the content is cut off as the slide background moves up.. What is a parallax-ish sliding content? How do you make a parallax-ish sliding content? This script and codes were developed by James Steinbach on 05 November 2022, Saturday.
Parallax-ish Sliding Content - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Parallax-ish Sliding Content</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="slide-container"> <div id="first" class="slide slide-one"> <h1>First Slide</h1> <p>Awesome content all over the place. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </div> <div id="second" class="slide slide-two"> <h1>Second Slide</h1> <p>Even more great content. Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur blandit tempus porttitor.</p> </div> <div id="third" class="slide slide-three"> <h1>Third Slide</h1> <p>You want more content? You got it! Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </div> <div id="fourth" class="slide slide-four"> <h1>Fourth Slide</h1> <p>Yes. More content. Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </div> <div id="fifth" class="slide slide-five"> <h1>Fifth Slide</h1> <p>This is the last of the content. No more. Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </div> </div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Parallax-ish Sliding Content - Script Codes CSS Codes
body { background: #000; text-align: center; font-size: 40px; font-family: Proxima Nova, Open Sans, Helvetica Neue, Helvetica, sans-serif; color: #ecf0f1; -webkit-font-smoothing: antialiased; font-smoothing: antialiased;
}
html,
body,
.slide-container,
.slide { height: 100%; width: 100%; position: relative; display: table; overflow: scroll;
}
.slide-container { height: 500%;
}
.menu { position: fixed; top: 0; width: 100%; text-align: center; z-index: 15; background: #ecf0f1; font-size: .5em;
}
.menu a { display: inline-block; padding: .25em 1em;
}
.slide { position: fixed; top: 0; left: 0; height: 100%; display: table-cell; padding: 0; overflow: hidden;
}
.slide-one { z-index: 10; background: #d35400;
}
.slide-two { z-index: 8; background: #2980b9;
}
.slide-three { z-index: 6; background: #16a085;
}
.slide-four { z-index: 4; background: #2c3e50;
}
.slide-five { z-index: 2; background: #7f8c8d;
}
.slide h1 { position: relative; top: 40%; margin-top: -2.25em; font-size: 3em; font-weight: 200;
}
.slide p { position: absolute; width: 20em; top: 10em; left: 50%; margin-left: -10em;
}
Parallax-ish Sliding Content - Script Codes JS Codes
$(window).scroll(function() { var windowHeight = $(this).height(), scrollDistance = $(this).scrollTop(), slides = $('.slide') slideCount = $(slides).length; $('.slide-container').css('height', slideCount*100+'%'); function slideReset() { $(slides).each(function() { $(this).css('height','100%'); }); }; if ( scrollDistance <= windowHeight) { var maxHeight = windowHeight - scrollDistance; slideReset(); $('.slide-one').css('height', maxHeight); } else if ( scrollDistance <= windowHeight * 2 ) { var maxHeight = windowHeight * 2 - scrollDistance; slideReset(); $('.slide-two').css('height', maxHeight); $('.slide-one').css('height', 0); } else if ( scrollDistance <= windowHeight * 3 ) { var maxHeight = windowHeight * 3 - scrollDistance; slideReset(); $('.slide-three').css('height', maxHeight); $('.slide-two').css('height', 0); $('.slide-one').css('height', 0); } else if ( scrollDistance <= windowHeight * 4 ) { var maxHeight = windowHeight * 4 - scrollDistance; slideReset(); $('.slide-four').css('height', maxHeight); $('.slide-three').css('height', 0); $('.slide-two').css('height', 0); $('.slide-one').css('height', 0); } else if ( scrollDistance <= windowHeight * 5 ) { var maxHeight = windowHeight * 5 - scrollDistance; $('.slide-five').css('height', maxHeight); $('.slide-four').css('height', 0); } console.log(scrollDistance);
});

Developer | James Steinbach |
Username | jdsteinbach |
Uploaded | November 05, 2022 |
Rating | 3 |
Size | 2,748 Kb |
Views | 8,092 |
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 |
Adding Shadow to SVG elements | 2,501 Kb |
Slip-Scroll - No JS | 5,556 Kb |
Moving Polygons | 3,143 Kb |
Content Blur under Fixed Header | 3,818 Kb |
Laser Hover Effect | 2,354 Kb |
Sphere Spin | 4,204 Kb |
Sass Geometric Pattern Generator | 2,020 Kb |
LOTR-ish Ring | 4,284 Kb |
Flip Card | 2,343 Kb |
Figure Eight Rotating Animation | 3,767 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 |
IE11 Test | Boostnewmedia | 4,998 Kb |
Pomodoro Clock | Yas46 | 3,328 Kb |
CSS3 Latte Art Logo | Esambino | 2,036 Kb |
Right Click Menu | Anodpixels | 2,252 Kb |
404 Error Page | WebSonick | 3,203 Kb |
Responsive slide | Thorien | 2,400 Kb |
A Pen by Moeid Saleem | Moeidsaleem | 1,862 Kb |
Part 19 Bootstrap split button dropdown | Venkatesha | 1,601 Kb |
Under construction | GhostRider | 1,642 Kb |
Ghost | Mghayour | 11,738 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!