用CSS判断横屏竖屏问题:
@media (orientation:portrait) { } 横屏
@media (orientation:landscape) { }竖屏
用JavaScript判断横屏竖屏问题:
window.addEventListener("onorientationchange"inwindow ?"orientationchange":"resize",function() {
if(window.orientation === 180 || window.orientation === 0) {
alert('竖屏状态!');
}
if(window.orientation === 90 || window.orientation === -90 ){
alert('横屏状态!');
}
},false);
网友评论