How can I fix the body on iOS while allowing the div to scroll smoothly?

To ensure full compatibility, I implemented a "hack" for older iOS devices by fixing the position of my page body. This prevents elements from scrolling and provides a solution to keep multiple page elements fixed on the screen of those devices.

I created a div that is meant to be scrollable. Only this div should have the ability to scroll, even on older iOS devices. However, it does not work as intended. When attempting to scroll, the body, which is fixed, scrolls instead of the scrollable element.

I set up an example that should allow scrolling down to number 23. However, it still does not scroll at all on older iOS devices. Despite making several adjustments that should facilitate scrolling, it remains unsuccessful on these devices.

What am I doing wrong?

body{
  width:100%;
  height:100%;
  text-align:center;
  position:fixed;
}

.contentwrap {
  overflow-y:scroll;
  -webkit-overflow-scrolling:touch;
  position: static;
  width:100%;
  height:100%;
}


<ul id="menu">
<li><a href="#page 1">Section 1</a>
<span><a href="#page 2">Section 1A</a></span>
<span><a href="#page 3">Section 1B</a></span>
<span><a href="#page 4">Section 1C</a></span>
</li>
<li><a href="#page 5">Section 5</a></li>
</ul>

<div class="contentwrap">1 <br> 2 <br> 3 <br> 4 <br> 5 <br> 6 <br> 7 etc...</div>

Complete codes to number 23:

https://jsfiddle.net/vf18x37n/

Answer №1

One way to ensure scrolling is enabled is by applying the !important rule to the scroll part of your code. This will take precedence over any conflicting styles.

For instance, you can use the following example:

#scroll {
    overflow-y:scroll !important;
   -webkit-overflow-scrolling:touch !important;
 } 

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

Using either Javascript or JQuery to update every cell in a particular column of a table

I need to use a button to add "OK" in the Status column of table tblItem, which is initially empty. How can I achieve this using JavaScript or JQuery? The table has an id of tblItem Id Item Price Status 1 A 15 2 B 20 3 C ...

An issue has occurred in the NSCocoaErrorDomain with error code 3840 related to an invalid escape sequence surrounding character 746

I encountered the following error message: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence around character 746." UserInfo={NSDebugDescription=Invalid escape sequence around character 746.} Below is the code I used to parse JSON: NS ...

Is there a way to make the product list view in Magento much more compact and smaller in size?

My issue is pretty straightforward. I find Magento's product display in list view to be too large for my liking. The images are bigger than necessary and each product takes up too much space. I want to resize the listing so that each product only occu ...

Having trouble sending information to HubSpot from the mobile app on your iOS device?

I'm currently facing an issue with my iOS code where a string of values is being combined to submit to Hubspot but the product string is not being included in the contact record. Below is the Swift code I have written: let params: [String:String] = [ ...

Add the component view to the webpage's body section

Using Angular 7 and ngx-bootstrap 4.0.1 Dependencies: "bootstrap": "3.3.7", "bootstrap-colorpicker": "2.5.1", "bootstrap-duallistbox": "3.0.6", "bootstrap-markdown": "2.10.0", "bootstrap-progressbar": "0.9.0", "bootstrap-slider": "9.8.0", "bootstrap-tags ...

Error encountered at /edit-menu/edit/: The 'Product' object does not contain the attribute 'is_valid'

I am attempting to extract all product names from the Product model, display them along with their prices on the screen, and enable users to modify the price of any item. Although I have managed to list them out and provide an input field for the price, I ...

Personalizing navigation tabs using Bootstrap

I've been working on creating a custom bootstrap navbar tabs, but I'm struggling to remove the borders and apply the custom colors. After some trial and error, here's what I have so far: .nav-tabs, .nav-pills { text-align: center; bo ...

What is the method for determining the position of the chosen text within a LiveCode field?

I'm trying to implement a feature where the field automatically scrolls to ensure the selected text remains visible after resizing. The challenge I'm facing is that I need to dynamically calculate the distance from the top of the field to the sel ...

Having difficulty inputting text into a text field using Selenium in Java

Here is a snippet of HTML code that I am working with: </td> <td valign=top bgcolor="#dcdcdc" class="camp"> <script>Oblog()</script>ID <br> <input ty ...

Alternative form for non-javascript browsers in the absence of script

I'm currently working on a landing page for an upcoming product, and I've run into a bit of a snag. <form novalidate method="POST" class="subscribe-form"> <noscript> </form> <form method="POST" action="/ ...

list without specific order spacing

I have implemented an unordered list in the footer section of my HTML document. Within this list, the first two items consist of social media logos displayed as images. To enhance their visibility and prominence within the footer, I have assigned them a wh ...

What is the best way to make my navbar reach the edges of the screen?

Currently working on a regular navbar, but aiming to have the logo and links span the entire container instead of starting in the middle. I'm seeking an easy solution that won't push out my links when applied. https://i.sstatic.net/nTFJ6.png ...

Sorting an array of objects in Swift iOS into separate arrays based on similar properties

I have an array of Super Hero objects that I need to group based on their name property, and then count how many objects are in each grouped array. Object: class SuperHero{ var name: String? var power: Bool? } Here is an example array of superhe ...

Creating a Personalized Tab Layout with react-bootstrap

Incorporating react-bootstrap components and styled components, I have implemented tabs in my project. The current appearance of the tabs is as shown here: https://i.sstatic.net/rPnlO.png However, my requirement is to have the tabs look like this inst ...

Tips for creating a responsive ReactJS website with Material-UI

I've been working on a reactjs project with material-ui, and everything looks great on desktop. However, when I switch to the mobile layout, all the text and images start overlapping. I'm wondering how I can make my site responsive. Below you&apo ...

Resolving the issue: "Error message: Command /usr/bin/codesign failed with exit code 1"

My attempts to code sign my first app have hit a snag - I can't seem to get it to compile without receiving the dreaded Command /usr/bin/codesign failed with exit code 1 error. To guide me through the process of code signing, I diligently followed th ...

What is the best way to design a polygon-shaped responsive div?

I've been attempting to design a unique layout with a pentagon-shaped div, however, I'm encountering some challenges. Despite using SVG for the shape, it does not display correctly in Firefox. Additionally, I need the div to be responsive and sca ...

Enhance navigation in your HTML5 iPad app with a swipe effect for seamlessly transitioning to the next page

I am in the process of creating a mobile application for browsing products offline on the iPad. The application will be developed using HTML5 / JS and will feature offline image caching and local storage. One of the key features I want to include is swipe ...

Why is my CSS Grid still not working correctly even though validation services have confirmed it is 100% correct?

After running my HTML and CSS through the validation services, everything seemed to check out fine. However, when I try to implement the grid layout using the CSS below, it doesn't seem to work as expected: body { display: grid; grid-template ...

Explore the Shopify assistance on the secondary blog section within a separate page

Hey there, I'm looking for someone who is familiar with Shopify and can assist me. I am currently trying to set up a secondary Blog section on a separate page from my default 'Blog Page', but I'm encountering issues in displaying the a ...