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,096 |
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 |
FlexBox Gallery | 2,205 Kb |
Sass Geometric Pattern Generator | 2,020 Kb |
Slip-Scroll - No JS | 5,556 Kb |
Sphere Spin | 4,204 Kb |
Moving Polygons | 3,143 Kb |
Swinging Door Menu | 9,013 Kb |
CSS Variables | 4,759 Kb |
Gradient Hover Effect | 2,212 Kb |
Using a gradient for a border | 2,138 Kb |
Flip Card | 2,343 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 |
Formations | Cantelope | 5,731 Kb |
Vue.js | Thommyboy02 | 1,506 Kb |
Flexbox slider | Rendro | 3,459 Kb |
A Pen by Jason Kinney | Jason-kinney | 1,980 Kb |
Drifting Clouds | Benedikte | 2,247 Kb |
Large canvas mousemove experiment | Jibbon | 2,885 Kb |
Toggle Time | Petebot | 5,345 Kb |
Cartoon Bomb | Tcmulder | 4,929 Kb |
Expert Help | SinceSidSlid | 4,064 Kb |
Wikipedia Viewer | Thomasvaeth | 2,549 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!