2014-10-31 76 views
2

我想迫使iPad仅在横向模式下显示网站?我可以强制iPad仅在横向模式下显示网站吗?

这可能吗?

+1

,将在波泰特模式做什么?什么都不显示 – laaposto 2014-10-31 15:26:15

+0

我的猜测是使用媒体查询来显示/隐藏基于宽度的内容。但那是在黑暗中拍摄的。你能提供更多细节吗? – trnelson 2014-10-31 15:27:11

+0

if screen.height> screen.width show icon把ipad变成风景? – Stefan 2014-10-31 15:27:54

回答

3

你可以用CSS设置:

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

} 
@media only screen and (orientation:landscape){ 
    /* your CSS */ 
} 

在波泰特模式下,所有elemnts将被隐藏。您可以设置<div>Switch to landscape</div>将只显示在波泰特模式

2

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

相关问题