How can I prompt user to rotate device if in a certain mode landscape or portrait, similar to GameInformer App

后端 未结 2 1573
迷失自我
迷失自我 2021-02-09 18:22

I have a website that is best viewed in Landscape mode. How can I have it so if the user loads the website in landscape mode it is fine but if it loads in Portrait mode or they

2条回答
  •  悲&欢浪女
    2021-02-09 18:52

    Instead of jQuery/JS you can use CSS with a styled div container instead, which is only shown when the device is in portrait mode.

    You can catch the orientation with a media query

    Example:

    /* for all screens */
    #info {display: none;}
    
    /* only when orientation is in portrait mode */
    @media all and (orientation:portrait) {
        #info {
             display: block;
        }
    }
    

提交回复
热议问题