Skip to content Skip to sidebar Skip to footer

Differentiating Portrait And Landscape Versions In Media Queries

I've got these media queries set. But how do I edit this to have separate media queries set for the portrait, landscape versions (e.g.: iPad, iPhone)? @media only screen and (min-w

Solution 1:

@mediaonly screen and ( orientation: portrait ) {}

@mediaonly screen and ( orientation: landscape) {}

I think thats what you are looking for.

Edit:

I think by fit in to my css you mean this:

@media (max-width: whatever) and (orientation: landscape) {}

If you are asking for a suggestion that when to use portrait or landscape, then use landscape when width of viewport is more and vice versa.

max-width: 1024px will set an upper limit and it will not interfere with rules for range: 1200px-1823px.

Solution 2:

We have to add orientation: portrait and orientation: landscape to your media screen.

iPad Landscape and Portrait

/* iPad Portrait */@mediaonly screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (orientation: portrait) 
  and (-webkit-min-device-pixel-ratio: 1) {

/* ur CSS */
}

/* iPad Landscape */@mediaonly screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (orientation: landscape) 
  and (-webkit-min-device-pixel-ratio: 1) {

}

For latest iPads use pixel ratio:2 (Retina display) .

-webkit-min-device-pixel-ratio: 2

Similarly for iPhone's, for iPhone's you have to set media for 4 different screens , < iPhone 4S , iPhone 5S and iPhone 6 and 6 plus versions.

Post a Comment for "Differentiating Portrait And Landscape Versions In Media Queries"