CSS如何判断横屏竖屏

竖屏引用

html竖屏HTML5在移动端若何断定阅读器是横屏照样竖屏 Docker

<link rel=\"大众stylesheet\"大众 media=\"大众all and (orientation:portrait)\"大众 href=\"大众portrait.css\"大众> 横屏引用

<link rel=\公众stylesheet\"大众 media=\"大众all and (orientation:landscape)\公众 href=\"大众landscape.css\"大众> css代码

@media screen and (orientation: portrait) { /竖屏 css/ } @media screen and (orientation: landscape) { /横屏 css/ } JS判断横屏竖屏方法

//判断手机横竖屏状态: window.addEventListener(\公众onorientationchange\公众 in window ? \公众orientationchange\公众 : \公众resize\"大众, function() { if (window.orientation === 180 || window.orientation === 0) { alert('竖屏状态!
'); } if (window.orientation === 90 || window.orientation === -90 ){ alert('横屏状态!
'); } }, false);