Media Queries only for the iPhone 4/4S! (Part II)
Using this code you will be able to add custom style rules only for the iPhone 4/4S. If you want to target iPhone 5 see this protip. If you prefer sass/scss syntax you should check my repository on github: sass-mediaqueries.
Only iPhone 4/4S (both: landscape and portrait)
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (-webkit-device-pixel-ratio: 2) and (device-aspect-ratio: 2/3)
{
...
}
Only iPhone 4/4S (portrait mode)
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (-webkit-device-pixel-ratio: 2) and (device-aspect-ratio: 2/3) and (orientation:portrait)
{
...
}
Only iPhone 4/4S (landscape mode)
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (-webkit-device-pixel-ratio: 2) and (device-aspect-ratio: 2/3) and (orientation:landscape)
{
...
}
Written by Rafal Bromirski
Related protips
1 Response
When you AND all those together with a "webkit" predicate, doesn't it negate the entire thing for non-webkit users?
Chrome/Safari will work, and since FF is not supported, it probably won't matter, but Opera and others won't get triggered. Just a thought.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css3
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#