html - iOS Safari: 100% width fixed position header wider than viewport -
i have run in problem effects safari on ios.
i building page has fixed position header width of viewport. content of page series of images (variable in number) should scroll right. header should remain in place when user scrolls.
on ios safari, fixed header, larger viewport, , scrolls @ different speed rest of content.
i've cut code down following, , still cannot work out how solve problem - following code works in other browsers have tested. (i targeting ie8+)
i've hosted example of problem here.
thanks advice , help.
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <style> html { font-size: 10px; height:100%; white-space: nowrap; } body { height:100%; padding:0; margin:0; } #dgs2 { height:75%; display:inline-block; } img{ height: 100%; } #pad{ height:6em; padding-bottom:1px; } #header{ position:fixed; width:100%; height:6em; border-bottom:1px solid; } .menuright{ float:right; } </style> </head> <body> <div id="header"> <div class="menuright"><h2>menu</h2></div> <h1>testing scroll on iphone</h1> </div> <div id="pad"></div> <div id="dgs2"> <img src='img/red.png'/><img src='img/blue.png'/><img src='img/red.png'/><img src='img/blue.png'/><img src='img/red.png'/><img src='img/blue.png'/><img src='img/red.png'/><img src='img/blue.png'/> </div> </body> </html>
i know question year old @ point, issue still exists in ios , had exact same issue fixed elements drifting, , driving me nuts. answer pretty simple: wrap div #bgs2 (or whatever element has "white-space:nowrap" on it) div.wrapper (the class unimportant obviously), , set overflow auto:
.wrapper { overflow: auto; -webkit-overflow-scrolling: touch; }
i added webkit-overflow-scrolling, helps avoiding repaints.
someone in future bound find bizarre issue, helps.
Comments
Post a Comment