Search code examples
cssresponsive-designlandscapeportraitlandscape-portrait

CSS responsive design - detect portrait display


I know it's with pure CSS possible to adapt the stylesheet according to screen dimensions, like this:

@media (max-width: 959px) {
  /* styles for smallest viewport widths */
}

@media (min-width: 600px) and (max-width: 959px) {
  /* styles for mid-tier viewport widths */
}

@media (min-width: 960px) {
  /* original CSS styles */
}

(source)

Is it with pure css possible to check on a landscape or portrait display?


Solution

  • Yes, using the following syntax:

    @media all and (orientation: landscape) {}
    

    See the w3 specs for more information.