2010-12-07 32 views
0

當iPhone更改爲肖像模式時,是否有使用JavaScript隱藏div元素的方法?iPhone方向HTML隱藏

+0

一個我自己的,[以前的問題( http://stackoverflow.com/questions/2323281/can-js-jquery-determine-the-orientation-of-the-iphone),可能值得快速閱讀。 – 2010-12-07 01:37:28

回答

1
@media all and (orientation:portrait){ 
    #divID { 
     display: none; 
    } 
} 

流行音樂,在你的CSS ;-)

0

你可以做一個可愛的小JS 「絕招」:

var elem = document.getElementById('elemID'); 
window.onorientationchange = function(){ 
    if(document.body.offsetWidth == 960){ //don't remember the best way to retrieve body width atm 
     elem.style.display = "none";  
    }else{ 
     elem.style.display = "block"; 
    } 
}