Safari is experiencing issues with overflow-x functionality after a device rotation

I'm currently in the process of developing a website that requires a specific div element to be horizontally scrollable if its content exceeds the screen size. This functionality works smoothly on most browsers, except for Safari:

Scenario: When the page is loaded in portrait mode on an iPad or iPhone, and the content within the scrollable div is larger than the screen, scrolling works as expected. However, upon rotating the device to landscape mode where the content now fits within the screen, the scrollbar disappears. Reverting back to portrait mode, the scrollbar reappears but scrolling stops functioning. A page refresh is then required to regain scroll functionality.

Issue Replication: You can replicate this scenario using the following fiddle: http://jsfiddle.net/v7wvbupd/2/. The issue persists with Apple products but not with Android devices.

While the scroll behavior performs well on mobile browsers other than Safari, I've attempted various solutions from different sources without success.

Attempts That Failed:

  1. Setting the position of the body to relative.
  2. Including html, body {overflow-x:hidden;}.
  3. Applying
    -webkit-overflow-scrolling:touch;
    to the scrollable div.
  4. Using !important with
    -webkit-overflow-scrolling:touch;
    and overflow-x:auto to prevent overriding when rotated.

Additionally, I explored JavaScript fixes like adding a timeout attribute, but these attempts also proved ineffective:

<script>
$("[scrollable]").css("-webkit-overflow-scrolling", "auto");
window.setTimeout(function () { $("[scrollable]").css("-webkit-overflow-scrolling", "touch") }, 100);
</script>

Most resources addressing scroll issues focus on total failure rather than my specific dilemma which only occurs upon rotation from landscape to portrait.

My Simplified Structure:

<html>
 <body>
  <div id="header" class="col-md-12"></div>
  <div class="scrollableDiv">
  <div id="footer" class="col-md-12"></div>
 </body>
</html>

Current CSS Implementation:

html {
overflow-y: scroll;
height: 100%;
width:100%;
}

body {
padding-top: 10px;
padding-bottom: 20px;
height: 100%;
width: 100%;
}

.scrollableDiv {
overflow-x: auto !important;
width: 800px;
overflow-y: hidden;
padding-bottom: 55px;
-webkit-overflow-scrolling: touch !important;
}

.col-md-12{
width: 100%;
}

EDIT

The site utilizes AngularJS as part of its solution. I ruled out JavaScript wrapping as the cause after testing, indicating a Safari-specific problem.

Answer №1

In the past, I encountered issues with Safari. Even simple tasks like handling overflow could turn into complex challenges.

My recommendation is to utilize iScroll. It is undoubtedly the ideal solution for situations like this.

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

CSS Hue Rotate is causing the image to appear darker

The CSS filter hue-rotate seems to be darkening my image according to my observations. For an example, visit: https://jsfiddle.net/m4xy3zrn/ Comparing images with and without the filter applied, it’s clear that the filtered one appears much darker than ...

Unable to transform dynamically loaded text area into CKEditor

Executing the get_content function upon a link click. function get_content(n) { var hr=new XMLHttpRequest(); var url="./updatecontent.php"; var vars="id="+n; hr.open("POST",url,true); hr.setRequestHeader("Content-type","application/x-w ...

The Multipart Parser encountered an unexpected end of stream error while in the starting state

i encounter this issue when attempting to submit a form link(rel='stylesheet',href='/stylesheets/home/profile/home_menu.css') script(type='text/javascript',src='/javascripts/perfil_editar.js') #logo_usuario img ...

Exploring the Depths of the Internet: Uncovering Data with BeautifulSoup

I am currently working on extracting the rain chance and temperature/wind speed data for each baseball game from rotowire.com. My goal is to organize this data into three columns - rain, temperature, and wind. I have made some progress with the help of ano ...

Clickable list element with a button on top

Within my web application, there is a list displaying options for the user. Each 'li' element within this list is clickable, allowing the user to navigate to their selected option. Additionally, every 'li' element contains two buttons - ...

css: Aligning fonts horizontally when they have varying sizes

First time asking a question on this platform! I'm attempting to achieve a "pixel perfect" horizontal alignment of two lines of text, with each line having a different font size. <style type="text/css"> * { font-family: sans-serif;} ...

Angular 8 implementation of a responsive readonly input text field styled with Bootstrap 4

I want to make the input text read-only using Bootstrap. After some research on the Bootstrap website, I discovered that the form-control-plaintext class can be used for this purpose. <input type="text" readonly class="form-control-plaintext" id="stat ...

What is the best way to preserve the updated sequence of a list that can be re-ordered?

I've been tasked with making a re-orderable list for my apprenticeship project. After incorporating drag and drop functionality using Jquery UI, I managed to display the index of each item. However, saving the new order back to the database has prov ...

CSS responsive design: concealing elements does not prevent the page from being displayed

Imagine a scenario where I need to display a template in two different versions based on the user's device. For instance, I have utilized the following code: <div class="desktop"> <body> Hi Desktop user </body> </div> ...

Activate outline styling for Bootstrap radio buttons when clicked

I was in the midst of developing my bootstrap application. Every time I click on a radio button, there is a noticeable blue outline as shown here: https://i.sstatic.net/Uzm7b.png I attempted to address this issue using the following CSS code: .form-chec ...

Unleash the power of CSS3 to style this button

I received an image of a button that I need to replicate on a website, but unfortunately, only the image was provided without any information about the font-family or size. Despite not being a designer or CSS expert, I attempted to create a CSS style that ...

The Bootstrap column class is malfunctioning

Recently, I've been diving into the world of web development. I attempted to create three divs in one row using Bootstrap col class, but unfortunately it didn't turn out as expected. Two divs ended up in a row with some blank space, while the thi ...

It appears that the query parameters are impacting the speed at which the page loads

I am currently developing a project on this platform. It is using c9.io, an innovative browser-based collaborative programming IDE. The index.php file includes the following script: <?php $path = ltrim($_SERVER['REQUEST_URI'], '/&ap ...

Achieving an italicized appearance throughout an HTML document

I recently downloaded a sample page from the Mathjax website and acquired their package from Github to use it locally. In addition, I wanted to incorporate the computer modern font, so I unzipped the file containing ttf files into fonts/cmu. Here's ...

The 'getGridMerchantLocationData' function contains duplicate definitions for both DataSource and DataSourceID. Please remove one of the definitions

I am having trouble binding data from a dataset. Can someone review my code and point out where I may be going wrong? The current issue is that it's not binding and throwing an exception: "Both DataSource and DataSourceID are defined on 'getGridm ...

What is the best way to close all other accordion tabs when selecting one?

A simple HTML code was created with the full pen accessible here. <div class="center"> <div class="menu"> <div class="item"> <button class="accordionBtn"><i class=&q ...

What is the best way to incorporate autoplay video within the viewport?

My objective is for the video to automatically start playing when it enters the viewport, even if the play button is not clicked. It should also pause automatically when it leaves the viewport, without the need to click the pause button. <script src=& ...

There was an issue with the SidebarController function being undefined, as it was expected to be a function

I'm encountering two issues with my demo: Error: [ng:areq] Argument 'SidebarController' is not a function, received undefined http://errors.angularjs.org/1.2.26/ng/areq?p0=SidebarController&p1=not%20aNaNunction%2C%20got%20undefined ...

Semantic UI dropdown field not displaying selected option text

I've encountered an issue while working with React Semantic UI. I'm trying to render a dropdown and have configured it so that the selected option's text should display in the field. However, when I choose an option from the dropdown, instea ...

Issue with Submit Button Functionality in Django Form Submission

I'm currently facing an issue with an HTML template I built using Bootstrap. My problem lies in the fact that I have a JavaScript function that dynamically adds rows to a Django form with specific fields whenever I need to. However, when I add a row, ...