2014-10-31 118 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

相關問題