判断手机横竖屏的条件

css:


@media all and (orientation : landscape) { 
		横屏
} 


@media all and (orientation : portrait){ 
		竖屏
} 

js:

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



猜你喜欢

转载自blog.csdn.net/qq_21262357/article/details/53693975