3 media queries for iphone portrait, landscape and ipad portrait

前端 未结 5 2054
北海茫月
北海茫月 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; 
        }
    }
    
    0 讨论(0)
  • 2021-02-01 11:51

    Media queries also support device orientation. You should try that

    @media screen and (orientation:portrait) {
        /* Portrait styles */
    }
    
    @media screen and (orientation:landscape) {
        /* Landscape styles */
    }
    

    You can also combine them with width like so

    @media screen and (max-device-width : 320px) and (orientation:portrait) {
    
    }
    
    0 讨论(0)
  • 2021-02-01 12:04

    Responsive emails can be tough because there are so many e-mail clients out there, and support can be limited for media queries. You may just want to look into making your divs fluid with percentages, so they scale, rather than media queries. The people at zurb have some great templates which may help out too. http://www.zurb.com/playground/responsive-email-templates

    Hope that helps.

    0 讨论(0)
  • 2021-02-01 12:06

    Take a look at this resource, will give you media queries for pretty much everything http://arcsec.ca/media-query-builder/ , you need to be be specifying a min width aswell. also less of the !important, dirty :)

    in your case

    @media only all and (min-device-width: 320px) and (max-device-width: 480px) {
    /* insert styles here */
    }
    
    0 讨论(0)
  • 2021-02-01 12:13

    i tried this by using Om's solution in a diff. way it worked for me, hope it helps someone

    @media only screen and (max-device-width:1024px) and (orientation: portrait)     {
        /*style*/    
        }
    @media only screen and (max-device-width: 1024px) and (orientation: landscape)  {
        /*style*/
    }
    
    0 讨论(0)
提交回复
热议问题