0

Is there a way using JavaScript to hide a div element, when the iphone changes to portrait mode?

Adele
  • 345
  • 1
  • 2
  • 10
  • One of my own, [previous questions](http://stackoverflow.com/questions/2323281/can-js-jquery-determine-the-orientation-of-the-iphone), might be worth a quick read. – David Thomas Dec 07 '10 at 01:37

2 Answers2

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

Pop that in your CSS ;-)

Ben Collier
  • 618
  • 4
  • 13
0

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";   
    }
}
stecb
  • 14,478
  • 2
  • 50
  • 68