My Website's Scrollable Divs Work Everywhere Except Mobile Safari - html

I'm working on a website, http://strange.business which is designed to load 5 random stories in 5 scrollable viewing divs. Note: There are only 2 stories right now.
There didn't appear to be any problem with that aspect of the page design, the divs would scroll without issue in Chrome, IE, Edge, etc. But I tried it on my gf's iPad Mini yesterday and the divs are locked for some reason. The stories do load, but they won't scroll.
The basic setup for those divs is thus:
#display1 {
background-color: white;
height: 350px;
overflow: auto;
}
#display1Inner {
width: 100%;
height: 100%;
overflow: visible;
}
<div name="display1" id="display1" title="Display1">
<span id="display1JavaWarning">You may need to enable
Javascript</span>
<object type="text/html" id="display1Inner"></object>
</div>
When the page loads, it executes a javascript function that picks a random preview htm file, and then populates the display1Inner object with that data. I'm aware that my coding could often be tighter, but it does generally work. Except on mobile Safari apparently.
I've tried a bunch of CSS variations after researching similar problems, but nothing seems to do the trick. That "overflow: visible;" bit was one of my latest attempts, but it wasn't present when I first noticed the problem. I don't know anybody with an iPhone (oddly enough) so I'm not sure if later versions of Safari still bug out on this, but the iPad I tested this on isn't that old. I should be able to make this work. Any thoughts?
PS. The page is still is a work in progress, sorry if you have a hard time navigating it.
ETA: Alright so I converted the page to use iframes inside nested divs, and now it works across platforms. So that much is solved. Yay!
Now though, I'm fiddling around trying to get rid of the double-scrollbars that appear when the page is viewed in desktop browsers. As I understand this workaround, IOS Safari totally disregards iframe height settings and displays them at full length. Hence the need for the iframe-wrapper div to keep that in check. And hence the extra scrollbar when I look at it in a "normal" browser window. If I disable scrolling on the iframe-wrapper div then it eliminates the double scrollbar, but also breaks scrolling in Safari.
You can view the most current incarnation at http://strange.business/test.htm. I'm open to suggestions.
ETA: Success! After setting the iframe heights to 99% and taking out the borders, they look just about like they did before, with no extra scrollbars. And scrolling works across platorms now. One less problem in the my life. Thanks for the help!

Have you tried the following CSS for your div:
-webkit-overflow-scrolling: touch;
overflow-y: scroll;
I came across that solution in this codepen:
https://codepen.io/kristiegiles/pen/WveNaX?editors=110
It is set up to scroll an iframe, but I tried it with some plain html in place of the iframe and it worked on my iPhone.
The html is basically a div wrapped around your content:
<h1>scrolling on iOS</h1>
<div class="content">
<div class="iframe-wrapper">
// Your content here
</div>
</div>
With -webkit-overflow-scrolling: touch; and overflow-y: scroll; added to the class applied to the div:
html,body{
height:100%;
}
.content{
width:100%;
height:100%;
overflow:hidden;
position:relative;
}
.iframe-wrapper{
position: absolute;
right: 0;
bottom: 0;
left: 0;
top: 0;
-webkit-overflow-scrolling: touch;
overflow-y: scroll;
}
Hope that helps.

Related

Hidden overflow and sticky elements

I want to prevent horizontal overflow for the body of the page and allow sticky elements at the same time. The solution seems simple at a first glance:
html {
overflow-x: hidden;
}
Everything works as expected on desktop. If you test it on mobile devices or choose a mobile device in Chrome dev tools, this will fail to work though. Apparantly, because touch devices ignore overflow-x: hidden for html and body tags as it's pointed out in many answers here on SO. So we have to use this instead:
html, body {
overflow: hidden;
}
However, this breaks sticky positioning. I know specifying the body height explicitely should fix the issue:
html, body {
height: 100%;
overflow: hidden;
}
body {
min-height: 100%;
}
Voila, everything seems to work well on mobile and desktop devices. However, this breaks window.onscroll event because it's the body that is scrolling now. So most of the scroll dependant libraries will fail to work (e.g. AOS). I kind of gave up at this point. Anybody has a solution to this? I'd love to avoid JavaScript solutions if possible.

overflow-x doesn't work on Safari after rotation

I am building a site where I need a certain div to be horizontal scrollable when overflown if the content is bigger than the screen. Okay, so this is easy - and it works on all browser but it doesnt work perfectly on Safari:
Scenario: Load page in potrait on iPad or iPhone. Content in the scrollable div is bigger than the screen. The scroll works fine. Now I rotate the screen to landscape and the content is now smaller than the screen and therefore there is no scrollbar. I rotate back to potrait, the scrollbar appears, but the scroll doesn't work. If I then refresh the page the scroll works again.
Duplication of the issue:
The scenario can be duplicated with this fiddle: http://jsfiddle.net/v7wvbupd/2/. If you go to this fiddle with an Android product it works perfectly with each rotation. If you do the same with an Apple product you will encounter the bug.
The scroll - with rotations - works fine on all other mobile browsers than Safari.
I have been trying out several things from other posts and other sites but with no success.
What I tried and didn't work:
Setting the postion of body to relativ.
Adding the following: html, body {overflow-x: hidden;}.
Use: -webkit-overflow-scrolling:touch; on the scrollable div.
Adding !important to -webkit-overflow-scrolling:touch; and overflow-x: auto to keep it from being overritten when rotatet.
I have also been looking into some js fixes like adding a timeout on the attribute but still with no results:
<script>
$("[scrollable]").css("-webkit-overflow-scrolling", "auto");
window.setTimeout(function () { $("[scrollable]").css("-webkit-overflow-scrolling", "touch") }, 100);
</script>
Most of the posts that I have come across are issues where the scroll doesn't work at all. In my situation it works until I rotate from landscape to potrait.
My structure (simplified):
<html>
<body>
<div id="header" class="col-md-12"></div>
<div class="scrollableDiv">
<div id="footer" class="col-md-12"></div>
</body>
</html>
My current CSS:
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
My site is using Angularjs as a part of the solution. I just tested if wrapping it within some js was the problem but this had nothing to do with it either. It seems to be a common problem with the Safari only?
I had this troubles with Safari by the past.
So simple things like overflow could become complicated ones.
I suggest you use iScroll.
Definetely the right solution for such a case.
http://cubiq.org/iscroll-5

Disable Elastic Scrolling in iOS Safari

I am trying to disable the elastic scrolling/bounce that is caused when pulling down from the top of an iOS Safari Page or vice versa at the bottom.
I have tried a technique below which I have seen people have said works but hasn't worked so far for me:
html,
body {
width: 100%;
height: 100%;
overflow: hidden;
#ios-scroll-wrapper {
overflow: auto OR scroll;
}
}
Is this something that is not able to be disabled now on iOS Safari? It's quite annoying to have as I have a fixed header/navigation at the top of the screen and pulling the page down causing the elastic scroll to either pull all content down apart from the header or with the above fix it will pull the content down and the header will disappear.
EDIT: Just as an FYI, this page/site is not using PhoneGap and a lot of solutions I have looked at so far use PhoneGap.
Try this:
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
As stated at Css-tricks

Strange css overflow like effect taking place

I've been using a twitter bootstrap based template.
For the images at the bottom of the landing page, for some reason there is an extra scrollbar that appears which then causes the images in the portfolio at the bottom to appear cropped, or partially loaded.
Not sure which bit of html or css is causing this, as the problem doesnt seem to occur in the original template. I've checked and compared my code to the original but cant figure out what's causing it.
I have removed alot of the code from the original as i dont need much of it. I just wanted a simple homepage, but cant figure what's causing the additional scrollbar or overflow effect.
Here is the page link if anyone has any ideas: http://krmmalik.com/photography/
The reference to the Ascensor.js is what's breaking the site and adding all that ugly inline CSS to the body. I have no idea what it's supposed to be doing honestly but it's breaking things at the moment. I disabled js on your site and reloaded it and everything works fine.
That layout isn't responsive as much as it is just a fluid layout. It doesn't resize well honestly. I hope it wasn't terribly expensive. Either that or something you changed broke how it is supposed to resize.
I'd try and find out what that script is supposed to be doing, but in the meantime just remove the reference and your site seems to load correctly.
I'm seeing this in Chrome dev tools:
<div class="house" id="house0" style="height: 268px; width: 1726px; overflow-y: scroll; overflow-x: hidden; margin-top: 0px; margin-left: 0px; position: absolute; ">
which sets a fix height, and then causes the second scroll bar when items drop below that height with the overflow-y:scroll; property.
However, this isn't in the View Source of your document! Getting rid of that is the key to fixing the problem, if you happen to know where it's coming from.
If you have control over it, maybe try changing it to:
<div class="house" id="house0" style="min-height: 268px; width: 1726px; overflow-x: hidden; margin-top: 0px; margin-left: 0px; position: absolute; ">
What this (should) do is make it never be shorter than 268px while allowing it expand to a new height, if it needs to. I say should because I didn't test it!
here is you made silly mistake. just remove overflow-x: hidden;
and overflow-y: scroll; and your code something like this.
<div id="house0" class="house" style="width: 1263px; margin-top: 0px;
margin-left: 0px; position: absolute;">
Hope it will helps you, Cheers. !!
Mark it as answer if it will helps so that other can fix their same problems. Thanks.

Webpage has a large right-margin in iOS

I have checked everything on my page and cannot figure out what is giving my website a large right-margin in iOS. It's driving me crazy. I've tried setting overflow: hidden; on the body to no avail. There is nothing that is wider than 960px. This is a very responsive design and all is working well except this one infuriating thing. Here is the URL to the dev site: http://ourcityourstory.com/dev/
Please see attached screenshot:
Any help would be appreciated.
Update: I've tried fooling with the viewport. See this Stackoverflow post. But to no avail. I built the entire site off of the HTML 5 Boilerplate
html,body
{
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow-x: hidden;
}
Add this to your CSS. then it should be working fine
The culprit was the Facebook share button. Instead of behaving like Twitter or Pinterest it iframes in and sets a width on the body of 500px!
A simple overflow: hidden; on my .social class fixed this.