Trouble with Scroll Snap and Navbar Toggle Malfunctioning on Browser Resize

I've run into a problem with scroll snap on my website. Every time the screen size changes, like when the mobile browser's navbar is opened or closed, the scroll snap behavior goes haywire. Even after returning to the top of the page, the snap feature doesn't work correctly. I've been grappling with this issue for a few days now without any luck in finding a solution. Can someone please lend me a hand in troubleshooting this issue?

Below is an excerpt of the code I'm currently using:

html {
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
main {
  max-width: 390px;
  margin: auto;
  top: 0;
  left: 0;
  right: 0;
}
.container {
  top: 0;
  position: sticky !important;
  margin: auto;
  border-radius: 15px;
  height: 100lvh;
  max-width: 390px;
  width: 100%;
  font-size: 48px;
  scroll-snap-align: start;
  font-size: 48px;
}
.container:nth-child(1) {
  background-color: red;
}
.container:nth-child(2) {
  background-color: blue;
}
.container:nth-child(3) {
  background-color: bisque;
}
.container:nth-child(4) {
  background-color: rgb(0, 255, 0);
}
.container:nth-child(5) {
  background-color: rgb(0, 255, 242);
}
<main>
    <div class="container">1</div>
    <div class="container">2</div>
    <div class="container">3</div>
    <div class="container">4</div>
    <div class="container">5</div>
</main>

https://codepen.io/norouzy/pen/wvONEev

I need help figuring out how to maintain scroll snap functionality even when the browser navbar is toggled. Any advice or suggestions would be highly appreciated. Thank you!

Answer №1

After spending a considerable amount of time attempting to create a stacking cards effect, I discovered that Chromium-based browsers are plagued with a bug related to this feature. This issue has been widely acknowledged and reported:

Fortunately, Safari does not suffer from this problem, so users may experience a partially functional version of the desired effect.

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

Adding a dynamic index from ngFor to an HTML attribute value can be accomplished by incorporating the current

I am using ngFor and I am trying to make an attribute inside the loop change its value by adding the ngFor index. This means that each div created within ngFor will have a unique attribute value. Source: <div class="class1" *ngFor="let item of items; l ...

What is the best method for populating a text area in Pharo with HTML content?

When logging in through Pharo using an HTML form, you can utilize the method of Znclient called formAt:add: followed by a post. I'm interested to know how I can fill a textArea in an HTML form and then make a post request. Is there a specific method f ...

Unique styling for underlines in pop-up with custom CSS

When exploring my codesandbox project, I encountered 2 questions: How can I create a custom underline CSS similar to the UI image below the file name and trash icon? I tried using text-decoration:none, but it doesn't match the UI. How do I center a U ...

Using select2, items can be automatically selected for an ajax call

Is it possible to configure a select2 control to automatically select an item when the ajax response contains extra data? I am looking to set up my controller to mark an item as an exact match in the JsonResult and have the select2 control automatically s ...

The TextField is currently unable to be edited because of an Uncaught TypeError stating it is not iterable

Currently, I am fetching data from an API and updating TextFields with it for display. My goal is to allow users to edit the data shown in these TextFields, but I keep encountering a Uncaught TypeError: prev.fields is not iterable error whenever I attempt ...

Utilize Google Earth Engine to specify bands when using the ee.Image.getDownloadURL() function

I am trying to specify certain bands along with a corresponding scale argument for each band in the getDownloadURL function, but I'm having trouble getting it to function correctly. var area = /* color: #d63000 */ee.Geometry.Polygon( [[[-3.199081 ...

What is the best way to show the current date and time in an Angular template while ensuring it stays up to

I'm looking to showcase the current date and time in my angular template, and have it automatically refresh when the time changes. The desired application LOOKS as follows: This snippet is from my .html template: <div class="top-right pull-right ...

"The occurrence of a `POST` error due to failed XHR loading can be attributed to Ajax

Attempting to execute a straightforward Ajax Request to transmit a JSON object from my Javascript file to my Python file in Django has presented a challenge. Occasionally, an error message XHR failed loading: POST pops up while executing it in the manner b ...

Deferred computed property fails to recognize the final character entered into the input field

I am facing an issue with my automated tests using selenium. The problem lies with a particular input field in a web form: <input data-bind="value: searchText, valueUpdate: 'afterkeydown'"></input> Here is the model associated with ...

Error: Unable to access the property 'map' as it is undefined | React, Redux

I'm encountering an issue that says: TypeError: Cannot read property 'map' of undefined. This error is related to trying to map over the array (posts) when it's empty: const postsList = posts.map((postList, i) => { Here is my actio ...

Understanding the Significance of this Regular Expression

I need assistance with regular expressions as I am not very familiar with them. The issue I am facing is related to a jQuery dynacloud plugin that stops working when a regex match occurs in my code. Can someone please help me understand what this regex mat ...

Implementing form validations using JavaScript for a form that is created dynamically

I have dynamically created a form using javascript and now I need to add mandatory validations on the form. The validations should trigger when the dynamically created button is clicked. However, I am facing an issue where I receive an error whenever I t ...

Guide to continuously play the animation, Version 2

I have been struggling with an animation that I need to loop indefinitely. The problem arises when trying to use animation-iteration-count: infinite. It seems like no matter where I place it in the code, whether within the keyframes or normal CSS rules, it ...

What is the method for altering the background color of an input field upon entering text?

As a beginner in Javascript and jQuery, I am struggling to understand why my code is behaving the way it does. I have written two similar functions aimed at changing the background color of an input field. The objective is to set the background color of t ...

JavaScript Routing with Multiple Files

I tried to access api.js from Routes.js, but I encountered an issue stating that the function my_function_in_api is not defined. Here is my code, could you please help me identify where the problem lies: Routes.js var val = require('file name') ...

Populating a span tag with data retrieved through Ajax

I encountered an issue with updating the totalDraftSalePrice HTML tag after a successful AJAX call. The data returned includes a field called SubtotalBasePrice, which I can visualize in JSON format, but for some reason, I am unable to update the HTML tag w ...

When using Vuepress behind a Remote App Server, pages containing iframes may return a 404 error

Creating a static website using Vuepress was a breeze, especially since I included a dedicated section for embedded Tableau dashboards. The website functioned perfectly when accessed online without any issues, displaying the Tableau dashboards flawlessly. ...

Leveraging promises in conjunction with mongoose operations

I'm new to using promises in conjunction with mongoose query functions such as find() and findById(). While everything seems to be functioning correctly, I am unsure if the way I am chaining then is the proper approach. The goal of utilizing promises ...

Having a newline between HTML elements can disrupt the structure of an HTML layout

It's common knowledge that in html, a newline between elements is treated as space. However, I find it quite alarming when working on responsive layouts. For instance, take a look at this example where the expected and correct behavior is achieved on ...

Transform the look of your bootstrap 5 inputs by making them dark-themed

I have a feature in my app that allows users to switch between light and dark modes. Currently, I am using Bootstrap 5 form-control inputs and want to customize their background color based on the mode selected. Which CSS classes do I need to target in or ...