CSS如何判断横屏竖屏
竖屏引用
<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);