Enable IFRAME support scrolling on iOS devices

Source: Internet
Author: User

Original link: Scroll IFRAMEs on IOS
Original date: July 02, 2014
Translation Date: July 10, 2014
Translators: Anchor

For a long time, elements beyond the bounds of safari on iOS devices will not scroll, and handling this problem has been a torment for developers.  For the original author's blog, this is particularly frustrating, because the demo program is running in the sandbox iframes, this is to not affect the blog site of the AJAX page loading strategy. Some studies have found that as long as you set two CSS properties, plus one element, this solves the problem. Here we go!
(Translator Note: The original self-tuning This problem is through the JS to monitor processing, the problem is the response is not very sensitive, and need to deal with a variety of browser compatibility issues.)
Click to view the sample program (you can open it with the iphone, the address is: http://davidwalsh.name/demo/scroll-iframes-ios.php)
Support for scrolling iframe page effectsHTML code
When using an IFRAME or other HTML element, you need to wrap them with an element such as a div:
<div class= "Scroll-wrapper" >    <iframe src= "" ></iframe></div>
This div will be used as the underlying container to support internal scrolling.

CSS Code
For an IFRAME to support scrolling, you need a common CSS property and a CSS property that few people know about:
. scroll-wrapper {    -webkit-overflow-scrolling:touch;    OVERFLOW-Y: scroll;    /* Tip: Please add the size (dimensions) or location (positioning) information you want to set here! */}.scroll-wrapper iframe {/    * your own specified style */}
-webkit-overflow-scrolling:touch;The property value is designed for elements that need to be scrolled when the browser overflows (overflow). If you do not specify this property, when you want to scroll the IFRAME, it will actually cause the outer page to scroll, through which you can control the IFRAME scrolling! In the original author's blog site, the following CSS was used:
. demo-iframe-holder {  position:fixed;   right:0;   bottom:0;   left:0;  top:0;  -webkit-overflow-scrolling:touch;  OVERFLOW-Y: scroll;}. Demo-iframe-holder iframe {  height:100%;  width:100%;}

Please bookmark this article for query or use. Remember that this CSS property is set on the wrapper element, not set to the scrolling element itself!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.