3 media queries for iphone portrait, landscape and ipad portrait

前端 未结 5 2088
北海茫月
北海茫月 2021-02-01 11:22

I have tried the different combinations of width & device-width but on the iPhone in landscape this code never turns the background red;

I

5条回答
  •  天涯浪人
    2021-02-01 11:51

    Your own attempt modified

    @media only screen and (max-width: 640px) and (orientation: portrait) {
        body { padding: 10px !important }
    }
    
    /* Small screen */
    @media only screen and (min-device-width: 320px) and (max-device-width: 479px) and (orientation: portrait) {
        body { background: blue !important }
    }
    
    /* iPhone landscape and iPad portrait */
    @media only screen and (max-device-width: 480px) and (orientation: landscape),
    @media only screen and (max-device-width: 640px) and (orientation: portrait)  {
        body { 
           background: red !important 
           -webkit-text-size-adjust:none; 
        }
    }
    

提交回复
热议问题