Languages
[Edit]
EN

CSS - style elements using media query with orientation

0 points
Created by:
Saim-Mccullough
688

In this article, we would like to show you how to style elements using media query with orientation in CSS.

Quick solution:

Where:

  • portret styles are applied to element when the viewport width <= height,
  • landscape styles are applied to the element when the viewport width > height.

 

Practical example

Edit

In this example, body element background will be yellow on portrait orientation (vertical) and orange on landscape orientation (horizontal).

 

See also

Edit
  1. CSS - viewport explanation

References

Edit
  1. orientation - CSS: Cascading Style Sheets | MDN
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join