CSS如何判断横屏竖屏

竖屏引用

html5设置横屏HTML5在移动端若何断定阅读器是横屏照样竖屏 React

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

<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);