Original link: Scroll IFRAMEs on IOS
Original date: 2014 71 months 02th
Translation Date: July 10, 2014
Translators: Anchor
For a long time, elements beyond the bounds of safari on iOS devices will not scroll, and dealing with such issues has been a torment for developers. For the original author's blog, this is particularly frustrating, because the demo program is executed in the sandbox iframes, this is to not affect the blog site of the AJAX page loading strategy. Some studies have found that the problem is solved by just setting two CSS properties and adding an element. 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 too sensitive, and need to deal with a variety of browser compatibility issues.)
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvcmvuznvmzwk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "/> Click to view Demo sample program (you can open it with iphone, address is: http://davidwalsh.name/demo/scroll-iframes-ios.php)
Support for scrolling iframe page effect HTML code
When using an IFRAME or other HTML element, you need to use an element, such as a div, to wrap them:
<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 CSS property that you use frequently and a CSS property that very few people know:
. scroll-wrapper { -webkit-overflow-scrolling:touch; OVERFLOW-Y: scroll; /* Tip: Add the size (dimensions) or location (positioning) information you need to set here! */}.scroll-wrapper iframe {/ * your own specified style */}
-webkit-overflow-scrolling:touch;The attribute value is designed for elements that need to be scrolled when the browser overflows (overflow). Assuming that this property is not specified, when you want to scroll the IFRAME, it actually causes the outer page to scroll, allowing you to control the scrolling of the IFRAME! 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 future reference or use. Keep this in mind. CSS provides wrapper element properties instead of the above scrolling element settings itself!
As an IFRAME on iOS your device supports scrolling