EN
CSS - style elements only for landscape orientation
0 points
In this article, we would like to show you how to style elements only for landscape orientation in CSS.
Quick solution:
xxxxxxxxxx
1
@media (orientation: landscape) {
2
.element {
3
/* put landscape styles here */
4
}
5
}
Where:
landscape
styles are applied to the element when the viewportwidth
>height
.
In this example, div
element background
will be orange
on landscape
orientation (horizontal) only.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
div {
7
width: 100%;
8
height: 500px;
9
}
10
11
@media (orientation: landscape) {
12
div {
13
background: orange;
14
}
15
}
16
17
</style>
18
</head>
19
<body>
20
<div>Web page content here...</div>
21
</body>
22
</html>