墨色风雨
可以判断,然后提示用户进行旋转if(window.orientation==90||window.orientation==-90){
alert("横屏状态!")
}或者监听旋转事件window.onorientationchange = function(){
switch(window.orientation){
case -90:
case 90:
alert("横屏:" + window.orientation); case 0:
case 180:
alert("竖屏:" + window.orientation); break;
}
}css的媒介查询也是能判断的@media (orientation: portrait) { } 横屏 @media (orientation: landscape) { }竖屏不过还是有解决方案的:打开页面时通过window.orientation可以判断网页是横屏还是竖屏,如果是竖屏,给整个页面添加样式transform: rotate(90deg);这样,你的页面就显示横屏的效果了。