我可以强制iPad只在横向模式下显示网站吗

Can I force iPad to show website only in Landscape mode?

本文关键字:模式 显示 网站 横向 iPad 我可以      更新时间:2023-09-26

我想强制iPad只在横向模式下显示网站吗?

这可能吗?

您可以使用CSS:进行设置

 @media only screen and (orientation:portrait){
    html body * {
         display:none;
    }
 }
 @media only screen and (orientation:landscape){
   /* your CSS */
 }

在门户模式下,所有元素都将被隐藏。您可以将<div>Switch to landscape</div>设置为仅在门户模式中显示

Safari的界面仍将处于人像模式,并且在将高度设置为100%时存在问题,但在人像模式下,您可以旋转整个html元素,如

html, body {
  height: 100%;
}
@media screen and (orientation: portrait){
    html {
        -webkit-transform: translateY(-100%) rotate(90deg);    
        transform: translateY(-100%) rotate(90deg);
        -webkit-transform-origin: left bottom;    
        transform-origin: left bottom;    
    }
}

或者查看http://codepen.io/ckuijjer/full/Frosl