Unable to get scroll snapping to function properly on Windows and various other devices

My webpage has scroll snapping enabled, which works well on Mac but not on certain devices (especially Windows), where it behaves like a regular scroll. This makes it difficult for visitors to read the content as they have to manually figure out where each section is located since scroll snapping is not functioning.

What would be a more user-friendly solution to address this issue?

.rightside {
  overflow-y: scroll;
  height: 100vh;
  scroll-snap-type: y mandatory;
}

.snap1 {
  scroll-snap-align: start;
  height: 100vh;
  position: relative;
}

.snap2 {
  scroll-snap-align: start;
  height: 100vh;
  margin-top: 100vh;
  position: relative;
}

.snap3 {
  scroll-snap-align: start;
  height: 100vh;
  margin-top: 200vh;
}

.snap4 {
  scroll-snap-align: start;
  height: 100vh;
  margin-top: 300vh;
}

.snap5 {
  scroll-snap-align: start;
  height: 100vh;
  margin-top: 400vh;
}
<div class="rightside">
  <div class="snap1">
    Page 1 : Hello world
  </div>
  <div class="snap2">
    Page 2 : Hello world
  </div>
  <div class="snap3">
    Page 3 : Hello world
  </div>
  <div class="snap4">
    Page 4 : Hello world
  </div>
  <div class="snap5">
    Page 5 : Hello world
  </div>
</div>

Answer №1

The following CSS property:

scroll-snap-type: y mandatory;

may not be compatible with older browser versions. To ensure compatibility, consider adding the following as well:

scroll-snap-type: mandatory;
scroll-snap-points-y: repeat(100vh);

This could potentially be causing the issue you are experiencing. For a more reliable solution that works across different browsers and gives you greater control, you may want to explore using an external library such as . This library also allows for normal scrolling if the section exceeds 100vh and then resumes snapping functionality afterwards.

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

Preventing an object from exceeding the boundaries of its designated space

My DIV is filled with user-generated content, which sometimes begins with an item that has a margin-top that overflows the container, creating a gap between it and preceding elements. I've discovered that changing the display property to either inline ...

How to adjust the timezone settings in PHPMyAdmin on a shared server platform

I'm having trouble changing my timezone to India on my shared server database. I've tried everything but can't seem to get it to work. My website is built using PHP Codeigniter The contact us page on my site saves all inquiry details to my ...

Center align `div 1` with CSS and right align `div 2`

Take a look at this code snippet: http://jsfiddle.net/zygnz/1/ <div class="container"> <div class="left"> LEFT </div> <div class="right"> RIGHT </div> </div> Is i ...

What is the best way to send data to PHP while moving objects between different div elements?

I have a situation where I have two parent divs containing dynamic children divs, and I want to enable POST requests to PHP when items are dragged from one side to the other (and vice versa). Here is the Javascript code I am using: function allowDrop( ...

Enable the option to customize the icon of the recently activated sidebar menu item

I need help with changing the arrow icon of a menu-item only when it is clicked, without affecting all other menu-items. In the image below, you can see that currently, clicking on any menu-item changes all the arrows. Attached Image //sidebarMenu jQu ...

What could be causing the vertical alignment issue of this logo in its parent container?

I am having an issue with the vertical centering of the logo element within the <header> container on this page. It seems to be more pronounced on mobile devices compared to desktop. However, the second element (#forum-link) is aligning correctly. W ...

PHP is struggling to retrieve the value of "img src"

CSS <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <form action="./test2.php" method="POST"> ...

Creating a masterpiece on the final piece of paper

As someone who is new to programming with JavaScript and canvas, I have a function called drawLines(canvasIndex, startPosition) that is used to draw lines on a canvas. The function takes in two arguments: canvasIndex, which represents the canvas being draw ...

What is the best way to include a subscript (small letter) beneath a word using html and css bootstrap 5?

Is it possible to add a small letter (sub) below a word in HTML and CSS? I have included a screenshot for reference. I want to display "Max 100, Min 1" just like shown in the image. Here is my code: <input type="text" class="textarea" ...

The background color of the columns is overwhelming

I would like to create a TV remote control design using bootstrap, but I am encountering some issues. The background color is overflowing and I'm unsure how to fix it. Please take a look at the code and feel free to offer any suggestions! @media scre ...

Customizing the default image of a Select dropdown field in Sencha Touch

Does anyone know how to change the default image of a select dropdown in Sencha Touch to a customized image? I've attached a screenshot for reference but can't seem to find any properties or classes to adjust this. Any guidance would be greatly a ...

Oddly stacked masonry tiles in a horizontal layout

After spending more than an hour trying to figure it out, searching and reviewing other solutions, I still haven't been able to resolve my issue. My problem is with 5 divs, where the third and fourth div are not stacking up as expected. Instead, the ...

Design a stylish outline for the element <div class="loader">

Initially, I managed to create a border around the body without any issues. However, I encountered a problem when attempting to implement a rotating border animation. In order to achieve this, I had to create a div encompassing all my content. The issue ar ...

An element that automatically adjusts to the height of the body

I have been struggling to make my div fit the body's height and always stay at the bottom when I scroll. Initially, I set it to 100% height but soon realized that this is not the correct solution. While scrolling, I noticed a gap between the bottom of ...

How can I ensure the text remains centered within a div, even when there are buttons aligned to the left or

I have a CSS class called .text-align-center that I used to center text. .text-align-center { text-align:center; } However, I noticed that when there is a left or right arrow icon within the <div>, the text does not appear perfectly centered. Is ...

what is the smallest browser width required to show the navigation bar collapse button?

Is it possible to adjust the browser width in order to display the collapse button for a navigation bar in Bootstrap? I believe media queries could assist with this, but I am unsure how to specify the minimum width of the browser window. ...

How can I utilize jQuery to iterate through every anchor tag on an HTML page?

I am looking to reference all anchor tags on the page that have a parent h2 tag. To achieve this, I need to iterate through each anchor tag that has a parent h2 and add an attribute using jQuery. <body> <h1>not me</h1> <a href ...

I'm attempting to slightly adjust the alignment of the text to the center, but it keeps causing the text to shift

I am facing an issue where I want to slightly center text, but whenever I add just 1px of padding-left, it moves to a new line. In my layout, I have 2 columns each occupying 50% width of the screen. One column contains only a photo while the other has a ba ...

In React, when utilizing the grid system, is there a way to easily align items to the center within a 5 by

I need to center align items within the material-UI grid, with the alignment depending on the number of items. For instance, if there are 5 items, 3 items should be aligned side by side in the center and the remaining 2 items should also be centered. Pleas ...

An hour ago, the Python and Selenium code was functional, but now it has suddenly ceased to work

Hello to all fellow community members, I recently attempted to locate the next button in Google search, specifically on the bottom right corner. Here is the HTML code snippet that pertains to this: <td aria-level="3" class="d6cvqb" ...