开发者

iPhone orientation HTML hiding

开发者 https://www.devze.com 2023-01-28 23:44 出处:网络
Is there a way using JavaScript to hi开发者_如何学Pythonde a div element, when the iphone changes to portrait mode?@media all and (orientation:portrait){

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

精彩评论

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