How to use javascript conditionally like CSS3 media queries, orientation?

前端 未结 6 1411
猫巷女王i
猫巷女王i 2020-11-29 19:37

How to use javascript conditionally like CSS3 media queries, orientation?

For Example I can write css for specific

@media only screen and (width : 10         


        
6条回答
  •  自闭症患者
    2020-11-29 20:40

    It's probably worth mentioning that there is the orientationchange event that you might want to hook into like so:

    $('body').bind('orientationchange', function(){
        // check orientation, update styles accordingly
    });
    

    I know that about this event being fired by mobile Safari, you'd have to check about other browsers.

提交回复
热议问题