Skip to content

Instantly share code, notes, and snippets.

@selbekk
Forked from pburtchaell/styles.css
Created August 6, 2015 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selbekk/1b331c35a728398dc9ee to your computer and use it in GitHub Desktop.
Save selbekk/1b331c35a728398dc9ee to your computer and use it in GitHub Desktop.
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
@mixin vh($heightPercentage) {
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*
* Original gist at from here: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
*/
height: #{$heightPercentage}vh;
/**
* iPad with portrait orientation.
*/
@media all and (device-width: 768px) and (device-height: 1024px) and (orientation: portrait) {
height: round(1024 * $heightPercentage / 100)px;
}
/**
* iPad with landscape orientation.
*/
@media all and (device-width: 768px) and (device-height: 1024px) and (orientation: landscape) {
height: round(768 * $heightPercentage / 100)px;
}
/**
* iPhone 5
* You can also target devices with aspect ratio.
*/
@media screen and (device-aspect-ratio: 40/71) {
height: round(500 * $heightPercentage / 100)px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment