Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Fix iOS 7 iPad Safari Landscape innerHeight/outerHeight layout issue
/**
* Add ipad IOS7 Classes
* Allows us to temporariliy try to fix the slight scroll 100% hack.
* http://stackoverflow.com/questions/19012135/ios-7-ipad-safari-landscape-innerheight-outerheight-layout-issue
*/
if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {
$('html').addClass('ipad ios7');
}
/**
* Fix for iPad iOS7 slight scroll on 100% body height
* http://stackoverflow.com/questions/19012135/ios-7-ipad-safari-landscape-innerheight-outerheight-layout-issue
*/
@media (orientation:landscape) {
html.ipad.ios7 > body {
position: fixed;
bottom: 0;
width: 100%;
height: 672px !important;
}
}

Many Thanks for your solution: it works.
I simply suggest to set height to match window.innerHeight and not a fixed value.
Setting fixed height leave a white band on full screen browser mode.
Something like this will works on full screen too (no jQuery needs) and chances are it will work even in case of an iOS fix:

<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<style>
html { position: fixed; top: 0px; bottom: 0px; width: 100%; }
</style>
</head>

...

<script type="text/javascript">
if (navigator.userAgent.match(/iPad;._CPU.OS 7\d/i))
{
document.getElementsByTagName("html")[0].style.height = window.innerHeight +"px !important";
}
</script>

undless commented Jul 22, 2014

Hi,

This trick worked perfectly for me too. Thanks benhuson.

jandelvo i think understand your point but for the moment there is no fullscreen mode on ipad IO7. But you're right, we should make it flexible.
I just suggest to add an orientation detection to your code because your code is setting a height even on portrait (the css use the media querie orientation:landscape).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment