The CSS Scroll-Snapping feature seems to be overlooking one specific element that it should be snapping to

Currently, this website is designed to work exclusively for mobile devices. When viewed in Chrome's mobile view using the inspector, everything appears to be functioning correctly. However, when accessed through Safari or on an actual mobile phone, there seems to be a problem where it skips over the second section that it should snap to. Below is the relevant code snippet:

function startGreet(){
  const greets = ["Hey","Hello","Good Morning"];
  const p = document.getElementById('greeting');
  p.innerHTML = greets[Math.floor(Math.random() * greets.length)];
}

/*   If reaches bottom of page do something code

window.onscroll = function(ev) {
    if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {

  }
};
*/
@keyframes jump {
    0% { transform: translate(0,0); }
    20% { transform: translate(0,-95%); }
    40% { transform: translate(0,15%); }
    60% { transform: translate(0,-10%); }
    80% { transform: translate(0,0%); }
    100% { transform: translate(0,0); }
}
body{
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling:touch;
}
html, body{
  position:absolute;
  overflow:auto;
  overflow-x: hidden;
  margin:0;
  height: 100vh;
  width:100%;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  background-color:white;
}
#greeting{
  position:absolute;
  width:100%;
  font-size:75px;
  font-family: 'Roboto Condensed', sans-serif;
  text-align:center;
  margin-top:75%;
  color:black;
}
#slideUp{
  position:absolute;
  height:5%;
  width:100%;
  font-size:70px;
  font-family: 'Roboto Condensed', sans-serif;
  text-align:center;
  margin:0;
  bottom:10%;
  color:#686868;
  -moz-animation: jump 2.5s 3s infinite;
-webkit-animation: jump 2.5s 3s infinite;
    -o-animation: jump 2.5s 3s infinite;
       animation: jump 2.5s 3s infinite;

}

#scrollCont{

  position:absolute;
  overflow: scroll;
  top:0;
  height: 100vh;
  width:100%;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: mandatory;
  scroll-snap-points-y: repeat(100vh);
  scroll-snap-type: y mandatory;
  -webkit-scroll-snap-stop: normal;
  scroll-snap-stop: normal;
}
.row{
  position: relative;
  width:100vw;
  height: 100vh;
  -webkit-scroll-snap-align: start end;
  scroll-snap-align: start end;
  scroll-snap-stop: always;
}
#home{
  position: relative;
  width:100vw;
  height: 100vh;
  -webkit-scroll-snap-align: none;
  scroll-snap-align: none;
}
#flower{
  width:150%;
}







#secondRow{
  color:black;
  word-wrap: break-word;
  background-color:#a0dfff;
  overflow:hidden;
}
#secondRow .title{
  padding-top:5%;
  color:black;
  font-weight: 100;
  font-family: 'Lato', sans-serif;
  font-size: 62.5px;
  margin-left:10%;
  margin-top:5%;

}
#secondRow hr{
  border-color: black;
}
#bodyCont{

  font-size:40px;
  position:relative;
  top:10%;
  left:10%;
  width:80%;
  color:black;
  font-family: 'Lato', sans-serif;
}

#thirdRow{
  background-color:black;
}
#thirdRow .title{
  padding-top:5%;
  color:white;
  font-weight: 100;
  font-family: 'Lato', sans-serif;
  font-size: 62.5px;
  margin:0;
  margin-left:10%;

}
#thirdRow hr{
  border-color: white;
}
<html>
<head>
  <link href="https://fonts.googleapis.com/css?family=Lato:300|Roboto+Condensed&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="mainMenu.css">
<link rel="stylesheet" type="text/css" href="indexR2.css">
<link rel="stylesheet" type="text/css" href="indexR3.css">
<script src="mainMenu.js"></script>
</head>
<body onload="startGreet()">
<div id="scrollCont">
    <div id="home">
    <h1 id="greeting" ></h1>
    <p id="slideUp" >^ ^ ^</p>
  </div>

  <div id="secondRow" class="row">
    <h1 class="title">Introduction</h1>
    <hr>
    <div id="bodyCont">
  <p><i>text text text text text</i></p>
  <img id="flower" src="https://cdn.pixabay.com/photo/2012/04/18/19/18/shrub-37619_640.png"/>
</div>
  </div>

  <div id="thirdRow" class="row">

  <h1 class="title">Introduction</h1>

  </div>

  </div>
  <!--<img id="videos" src="https://www.sccpre.cat/mypng/full/15-156384_old-camera-png-camera-drawing-transparent-background.png"/>-->
</body>
</html>

Please note that this website is intended to function properly only on mobile devices, so viewing it on other devices may result in formatting issues.

Answer №1

Have you considered including the -webkit- prefix for your keyframe? It's important to remember that for Safari on iOS, you will need to use the vendor prefix -webkit- (as outlined on developer.mozilla.org). Here is an example:

@-webkit-keyframes jump {
0% { transform: translate(0,0); }
20% { transform: translate(0,-95%); }
40% { transform: translate(0,15%); }
60% { transform: translate(0,-10%); }
80% { transform: translate(0,0%); }
100% { transform: translate(0,0); }
}

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

How do I hide a div if its contents exceed the available space in CSS?

On mobile screens, one of my divs is displaying below the navigation bar and I want to hide it using pure CSS. Can anyone suggest a solution? I've attempted using "text-overflow: hidden;" and "overflow: hidden;" but they don't seem to be working ...

Find and target all CSS elements that have the property of "display: inline

Can the CSS be searched by property:value instead of selector/attribute? Or does this require parsing through a server script? If it is achievable, I am considering developing a script that will automatically include the IE7 hack when the selector contain ...

Visual Latency when Quickly Toggling Between Images in Succession

I have a series of 50 images that need to be displayed sequentially inside a div. The time interval between displaying each image is initially set at 750 milliseconds and decreases with each subsequent image. To ensure all images are loaded before the an ...

Removing an element that is floated inside a parent element with other floated and non-floated siblings in Chrome

Can someone help me with this code issue? <!doctype html> <title>Test case</title> <div style="float: left"> <div style="float: left;">Short.</div> <div></div> <div style="overflow: hidden;"&g ...

Tips for showing more rows by clicking an icon within an Angular 2 table

When I click on the plus (+) button in the first column of each row, only one row expands. How can I modify it to expand multiple rows at a time? Thanks in advance. <div> <table class="table table-striped table-bordered"> <thead> ...

Display a modal when clicking on a bootstrap glyph icon

I tried following a tutorial on how to create a Bootstrap modal at https://www.w3schools.com/bootstrap/bootstrap_modal.asp However, I would like to use a glyph icon in the code snippet like this: <span class="glyphicon glyphicon-pencil" class="btn btn ...

Guide on resetting the default background image of a button in Objective-C

Currently, I am working on modifying an app created by someone else. One of the changes I want to make is allowing users to switch their answer selection before submitting it. The challenge I face is not being able to locate the original image used for the ...

receiving error notification from struct that conforms to Codable

Deciphering a JSON structure is currently my task, and in case the decoding process fails, it indicates that one of the fields is absent from the server's response. My aim is to inform the user about this missing field. Here is the structure being de ...

Restricting the number of lines within a paragraph in Angular 2

Is there a method to limit the number of lines in a <p> tag and add an ellipsis (...) at the end? Using character count for truncation doesn't work well as the width of the element varies according to device screen size. ...

jQuery Animation: Creative Menu Icon Display

Whenever the toggle menu's navigation icon is clicked, it triggers an animation that transforms the "hamburger" icon into an "X", causing the navigation menu to drop down. If a user clicks either the navigation icon or outside of the active toggle me ...

Modify the hover color of heading 1 only for hyperlink texts

I am attempting to adjust the hover color specifically for text that contains a link. Below is the CSS code I have tried, but it changes the color regardless of whether there are links present or not. h1, h2, h3, h4 { color:#3F3F3F; } h1:hover, h2:hove ...

Adjusting the width of columns in a flex layout using Bootstrap 4

On mobile, I am attempting to rearrange some elements in a different order. Currently, this is what I have: https://i.stack.imgur.com/fY3PQ.png Below is the HTML code: <main> <div data-color="yellow"></div> <div class="wrapper"& ...

Vertically align all items within the div using Bootstrap to achieve perfect centering

I've been working on centering everything within this div vertically, and I've encountered some challenges along the way. Initially, I ensured that my background view extends my container nicely across the screen. Now, I'm looking to create ...

Is there a way to ensure a grid container occupies the entire page?

Having trouble getting my grid display to cover the full size of the page. I have a grid with three columns controlled by two elements but it is not taking up the entire screen as expected. How can I make the grid fullscreen? .wrapper { display: grid; ...

Tips on organizing and designing buttons within a canvas

let canvas = document.getElementById("canvas"); let context = canvas.getContext("2d"); // for canvas size var window_width = window.innerWidth; var window_height = window.innerHeight; canvas.style.background="yellow" canvas.wid ...

Use jQuery to permit only numeric characters and the symbol "-" to be entered into a textbox

I have been working on a JQuery script that only allows users to input numbers in a text field. However, I am now trying to modify the code to also allow users to enter "-" (hyphen), but so far it's not working as expected. If anyone can provide assis ...

Is there a way to position these divs in a line using inline-block?

I need help aligning two divs with text differently - one to the top left and the other centered but not on the same line. Here's the layout I'm aiming for: ---------------------------------------------- |Backstage |Issue 4 | | ...

Creating a dropdown menu with a blur effect using CSS

I attempted to match the opacity and blur effect of my dropdown menu with that of my navbar. While the opacity adjustment worked correctly, the blur effect did not apply as expected. I've heard that I need to utilize a pseudo-class to achieve this, b ...

Nextjs exposes a bug in react-bootstrap's navbar component

After integrating react-bootstrap with nextjs, I encountered a strange issue with the NavBar component. The problem arises when I first load the navbar - everything appears as expected, https://i.stack.imgur.com/R9guE.png but upon refreshing the page, CS ...

Error concerning variable scope outside of block in Xcode

I am currently facing an issue with assigning URLs to the Content.link cases that are being loaded from a file in a preceding block (getWebData). The interesting part is that I can see that it's working as expected, based on the log. However, what pu ...