I am developing a smartphone friendly version of a website and I am facing a little problem while working with the media query for the smartphone landscape orientation. For the portrait orientation, I am using the following media query and it's working perfectly fine:
@media only screen and (max-width : 320px) { style goes here }
but when i am using this media query for the landscape orientation (taken from css-tricks.com), the styles which I write for the landscape orientation overwrite the styles which I've put in for the desktop version of my website.
@media only screen and (min-width : 321px) { style goes here }
This is only happening when I am inserting styles for the landscape orientation, this doesn't happen when I assign styles for the portrait orientation.
P.S I am doing the testing on an iPhone 4.
Media queries can also be used to change layout of a page depending on the orientation of the browser. You can have a set of CSS properties that will only apply when the browser window is wider than its height, a so called "Landscape" orientation.
“Media orientation” refers to the attitude of communication professionals towards mass media. It can be used as an indicator of the status of mediatisation within organisations on the individual level of communication professionals (Kohring, Marcinkowski, Lindner, & Karis, 2013.
only screen: The only keyword is used to prevent older browsers that do not support media queries with media features from applying the specified styles. Syntax: @media only screen and (max-width: width)
You need to set a max-width for your landscape orientation, this won't overwrite your desktop styles until the width is lower than 800px:
@media only screen and (min-width : 321px) and (max-width: 800px) { style goes here }
The other possibility is to wrap your desktop styles into another query and copy them below your portrait and landscape styles:
/* PORTRAIT STYLES */
@media only screen and (max-width : 320px) { style goes here }
/* LANDSCAPE STYLES */
@media only screen and (min-width : 321px) { style goes here }
/* DESKTOP STYLES */
@media only screen and (min-width : 800px) { style goes here }
Note that the Landscape styles will be used for the Desktop version. Sometimes this is a welcome behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With