Sticky full-height slider with horizontal scrolling

I've been working on creating a horizontal slider animation that smoothly scrolls, inspired by the one showcased on

The slider on weltio remains sticky as you scroll, showcasing images and content within.

On my page, I have a lot of content and my goal is to have the div occupy the screen when scrolled to, and as you continue scrolling, the content changes seamlessly.

-------------------------------------------------------------------------------

Despite extensive research and searching for examples, I have not been able to achieve the smooth, sticky, animated design that I am aiming for. It seems there aren't any similar examples available online for me to use.

The code snippet below is the latest solution I've tried, but it still lacks that smoothness I'm looking for. The scroll on the page is noticeable, whereas I want it to be fixed in place, giving that same smooth effect demonstrated on weltio.

.contain {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: auto;
  scroll-behaviour: smooth;
  scroll-snap-type: y mandatory;
}

.sec {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: centre;
  background: #f00;
  scroll-snap-align: center;
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
  background-blend-mode: multiply;
}

h3 {
  color: #ffffff;
  font-size: 10vw;
  text-align: center;
  margin: 0 50px;
}

.sec:nth-child(1) {
  background: #f00 url(./big-bgr.png);
}

.sec:nth-child(2) {
  background: #0f0 url(./big-bgr.png);
}

.sec:nth-child(3) {
  background: #ff0 url(./big-bgr.png);
}

.sec:nth-child(4) {
  background: #f436ee url(./big-bgr.png);
}

.sec:nth-child(5) {
  background: #00f url(./big-bgr.png);
}

.content {
  position: absolute;
  top: 0;
  width: 100%;
  text-align: center;
}

.content h2 {
  position: relative;
  display: flex;
  justify-content: center;
}

.content h2 span {
  position: sticky;
  top: 0;
  line-height: 100vh;
  height: 100vh;
  color: #ffffff;
  font-size: 14vw;
  margin-top: calc(100vh * var(--i));
}
<div class="banner">
  <div class="contain">
    <div class="sec">
      <h3>Scroll Down</h3>
    </div>
    <div class="sec"></div>
    <div class="sec"></div>
    <div class="sec"></div>
    <div class="sec"></div>

    <div class="content">
      <h2>
        <span style="--i:1;">T</span>
        <span style="--i:2;">E</span>
        <span style="--i:3;">S</span>
        <span style="--i:4;">T</span>
      </h2>
    </div>
  </div>
</div>

Answer №1

The desired effect cannot be achieved using just HTML and CSS.

Weltio achieves the effect by scrolling all content with transform: translate3d() and smoothing out the scrolling position with JavaScript.

To replicate the scrolling effect of Weltio, you need to first disable the native scrolling by applying overflow: hidden to the body element.

Next, you need to listen to user scrollwheel input and keep track of how much the user has scrolled. Use this code snippet:

window.addEventListener("wheel", event => desiredScroll += event.deltaY);
. (Remember to handle touch devices separately)

Finally, continuously update the actualScroll value to smoothly approach the desiredScroll. You can utilize requestAnimationFrame for this purpose.

...

Now you have a basic setup for smooth scrolling. The next step would be to implement scroll stop to prevent scrolling beyond the content height. Additionally, you can add a rubber band effect for a more dynamic scrolling experience.

...

Now you have a smooth scrolling system. To enhance the experience, consider adding snapping points. This can be achieved by making elements the same height as the screen and implementing a snapping behavior with each scroll.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Fundamentals of object property in jQuery and Javascript

Currently working on creating a new property named startPosition and setting the top property to equal the button's current top value in CSS. Below is the jQuery code snippet: var morphObject = { button: $('button.morphButton'), c ...

Preserve proportions while resizing the browser window

I needed my code to ensure that the images keep their aspect ratio regardless of the screen size or if the user resizes their browser instead of viewing it full screen. I have some code in place, but I'm unsure how to maintain the current effects of ...

Testing tools for ensuring the functionality and design of the mobile version of a

Is there a way to preview how my website will appear on mobile before it goes live? Most tools I've come across only work for hosted sites. ...

Is it possible that adding html tables together could result in the numbers being concatenated instead of summed?

When attempting to calculate the total sum of values in an html table column, my variable seems to be returning concatenated strings instead of the actual sum. For example, instead of 1 + 2 + 3 = 6, I am getting 1 + 2 + 3 = 123. The values in the "votes" ...

Mastering the art of flawlessly executing kerning-generated code

I am facing a problem while implementing logotext with kerning technique in the <header> element. I found a useful tool made by Mr. Andrew which can be accessed through this link. Before making any modifications, I had the following code in the heade ...

How can you conceal nested elements within a layout that adjusts to various screen sizes or is percentage-based

Contemplate this HTML: <body> <div id="parent"> <div id="child"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dapibus sapien congue, fringilla justo quis, aliquam tellus. Maecenas semper consectetur metus ege ...

Preventing scrolling in one div while focusing on another div

I am currently in the process of creating a website that functions as a single page site. The main feature of the site is a masonry grid of images. When a user clicks on an item, a detailed panel slides in from the left. Once the panel is closed, it slide ...

Objects and strings cannot be inserted into a JavaScript array

For hours, I've been attempting to troubleshoot this code. Currently, it successfully finds the number of anchors, and I have an array that is of undetermined size. Within the for loop, it retrieves the anchor and extracts the .href. I've confirm ...

Generating a table with two columns utilizing ng-repeat

I am currently dealing with an array of objects that I need to showcase in a two-column layout. The challenge arises because some columns have more data than others, requiring equi-height rows. Despite utilizing Bootstrap and clearfix in my attempts to di ...

The :empty selector is failing to function properly in @media print queries

Currently, I am working in Twig on Symphony and have encountered an issue with an empty div that needs to be hidden in print mode. <div class="form-fields__list"> </div> Surprisingly, the :empty selector works perfectly fine on the screen, bu ...

Title slide on quarto featuring a captivating full coverage background image with a sleek row of icons at the bottom

I am currently working on creating a title slide for a reveal.js presentation in Rstudio using quarto. My goal is to have a background image covering the entire slide and include one or more small icons at the bottom (specifically on this slide only). I ha ...

Ensure that the div stays anchored to the bottom of the page while maintaining its

Although I know this question has probably been asked and answered before, I couldn't find any useful solutions to my specific problem... I'm attempting to position a chat box div at the bottom of a page without being fixed, while still maintain ...

Uploading profile photos via PHP and storing in a database

I am encountering an issue where the uploaded photo appears on the site but its corresponding name is not being saved in the database. The code successfully uploads the photo to the site but unfortunately, the file name is not being stored in the database. ...

Is it possible for me to designate a specific class for the rev value?

<a href="img1.jpg" rel="zoom-id:bike" rev="img1.jpg"> <img src="" class="img-thumb"/></a> Shown above is a snippet of HTML code. I wonder if it's possible for the attribute rev="img1.jpg" to have a class that only affects the s ...

Tips for adjusting the search bar's position on a mobile device when it is activated by the user

I need help with an open source project where I am developing a search engine using Angular. When using smaller screen sizes, the search bar is positioned in the middle but gets hidden behind the keyboard terminal when clicked on. Can anyone advise on ho ...

Focus on selecting each label within a table using JavaScript

In my current setup, I am attempting to customize radio buttons and checkboxes. Array.from(document.querySelectorAll("tr")).forEach((tr,index)=>{ var mark=document.createElement("span"); Array.from(tr.querySelectorAll("input")).forEach((inp,index ...

Avoid creating a line break directly after the header, however allow for a line break

I find myself in a scenario where I require a paragraph that has a specific format: An Emphasized Title Some relevant information regarding the subject... I am looking to insert a new line before the title, ensuring it seamlessly integrates with the re ...

Gmail not displaying image - troubleshoot with Django Python-Postmark

Having trouble displaying static images in Gmail when using django python-postmark for mailing. Gmail is appending a url proxy to the src of the images, which causes them not to display properly. What might I be missing here? How can I solve this issue? Th ...

Exploring the Interactive Possibilities of CSS3 with Background Tiles

I'm struggling to implement a flip effect where the content of a div changes, but I can't seem to prevent the text from disappearing after a few seconds. I've tried using backface-visibility:hidden with no luck! HTML <div class="cards" ...

In React Native, changing the translation of an element causes it to shift below all other elements, regardless of

Check out this sandbox project: I'm trying to create a simple animation using translation in React Native, but I'm facing an issue where when I move the element to the right and down, it goes under other elements. However, if I move it left and ...