How to determine if a device is in portrait or landscape mode using CSS

こ雲淡風輕ζ 提交于 2019-12-10 20:57:28

问题


For determining screen size I'm using media queries but I want determine if a device is in portrait or landscape mode using CSS so that I can have different background image as per screen size.

Any thoughts?


回答1:


simply write media queries for landscape and portrait modes:

/* Portrait */
@media screen and (orientation:portrait) {
/* Portrait styles */
}
/* Landscape */
@media screen and (orientation:landscape) {
/* Landscape styles */
}

link here



来源:https://stackoverflow.com/questions/19288816/how-to-determine-if-a-device-is-in-portrait-or-landscape-mode-using-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!