如何使用CSS确定设备是处于纵向还是横向模式

May*_*rma 3 css3 media-queries landscape-portrait responsive-design

为了确定我正在使用的屏幕尺寸,media queries但我想确定设备是否在,portrait or landscape mode using CSS以便我可以根据屏幕尺寸具有不同的背景图像.

有什么想法吗?

use*_*971 21

只需为横向和纵向模式编写媒体查询:

/* Portrait */
@media screen and (orientation:portrait) {
/* Portrait styles */
}
/* Landscape */
@media screen and (orientation:landscape) {
/* Landscape styles */
}
Run Code Online (Sandbox Code Playgroud)

链接在这里

  • 在HTML5**媒体屏幕******全部**,请参阅:http://stackoverflow.com/questions/12549267/media-all-vs-media-screen (2认同)