开发者

iPhone orientation HTML hiding

Is there a way using JavaScript to hi开发者_如何学Pythonde a div element, when the iphone changes to portrait mode?


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

Pop that in your CSS ;-)


you could do a lil js "trick":

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";   
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜