貌似我來晚了黨......我的解決方案是任何移動設備上未經檢驗。所有更改都在CSS(style.css
)上註釋,並且標記只有一個修改:scrolling="no"
至iframe#foo
。
PLUNKER
HTML
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<div id="container">
<iframe id="foo" frameborder="0" scrolling='no' marginwidth="0" marginheight="0"
src="//www.iana.org/domains/reserved"></iframe>
</div>
</body>
</html>
CSS
/* S.O. 33571717 */
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/* NOTE: This style is contingent upon the iframe #foo... */
/* having the attribute: scrolling="no" */
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html,
body {
/* If html is 100%... what is html's parent? 100% of nothing? */
/* Having +100% unit higher than max will extend overflow: auto */
/* Using vh and vw units to ensure accurate viewport dimensions... */
/* see http://goo.gl/yQZX8v */
height: calc(100vh + 100%);
/* set as vh instead of % */
width: 100vw;
/* set as vw instead of % */
margin: 0;
padding: 0;
/* split overflow's axis */
overflow-y: auto;
overflow-x: hidden;
}
#container {
/* changed from fixed */
position: relative;
top: 0;
left: 0;
height: 100%;
width: 100%;
/* split overflow's axis */
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
#foo {
height: 100%;
width: 100%;
/* added #foo to 'flow' of #container */
position: absolute;
/* #foo is stretched to every corner of #container */
top: 0;
bottom: 0;
left: 0;
right: 0;
/* split overflow's axis */
overflow-y: auto;
overflow-x: hidden;
}
/* THIS HAS NOT BEEN TESTED ON ANY MOBILE DEVICES */
/* This media query is DEVICE specific to an iPhone 6+ */
/* NOTE: Use media queries for landscape and portrait mode... */
/* the properties are reversed basically */
/* iPhones do not follow a simple logic for media query dimensions... */
/* see http://stephen.io/mediaqueries/ */
@media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (orientation : landscape){
html, body {
overflow-y: hidden;
overflow-x: auto;
height: 100vh;
width: calc(100vw + 100%);
}
#container {
overflow-x: auto;
}
#foo {
overflow-y: hidden;
overflow-x: auto;
}
}
請審覈並測試我在iPhone上的解決方案。我很好奇它是否成功,但對購買iPhone不是很好奇。 :P – zer00ne
我沒有打擾測試,因爲在桌面瀏覽器中查看時存在兩個滾動條。 – Patrick
更新後的http://plnkr.co/edit/QkF05lhU3dH3qhn7JQ7N?p=preview – zer00ne