How to target Galaxy Nexus and Nexus 7 with media queries?

前端 未结 7 1681
难免孤独
难免孤独 2020-12-30 05:58

I have two devices that I\'m testing site design with. Samsung Galaxy Nexus and Asus Nexus 7 tablet. I\'m having a really hard time figuring out how to target these individu

相关标签:
7条回答
  • 2020-12-30 06:06

    you can use the and expression to use multiple rules to the same media query

    @media screen and (min-width: 998px) and (max-width: 999px)
    

    target any between 998px and 999px

    0 讨论(0)
  • 2020-12-30 06:13

    Nexus 7 (v1) 2012

    Mozilla/5.0 (Linux; Android 4.4.3; Nexus 7 Build/KTU84L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Safari/537.36
    
    @media screen
    resolution: 192dpi/2dppx
    color: 8
    -webkit-device-pixel-ratio: 2
    
    orientation: portrait
      width: 600px/37.5em/158mm
      height: 791px/49.4375em/209mm
      device-width: 600px/37.5em/158mm
      device-height: 960px/60em/254mm
      aspect-ratio: 600/791
      device-aspect-ratio: 5/8 or 758/1000
    orientation:landscape
      width: 960px/60em/254mm
      height:431px/26.9375em/114mm
      device-width:960px/60em/254mm
      device-height:600px/37.5em/158mm
      aspect-ratio:960/431
      device-aspect-ratio:8/5 or 2227/1000
    

    Nexus 7 (v2) 2013

    Mozilla/5.0 (Linux; Android 4.4.2; Nexus 7 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Sfari/537.36
    
    @media screen
    resolution: 127dpi/1dppx
    color: 8
    -webkit-device-pixel-ratio: 1.3312500715255737 or 1.3
    
    orientation: portrait
      width: 601px/37.5625em/159mm
      height: 881px/55.0625em/207mm
      device-width: 601px/37.5625em/159mm
      device-height: 962px/60.125em/254mm
      aspect-ratio: 601/881
      device-aspect-ratio: 601/962
    orientation: landscape
      width: 962px/60.125em/254mm
      height: 529px/33.0625em/114mm
      device-width: 962px/60.125em/254mm
      device-height: 601px/37.5625em/159mm
      aspect-ratio: 962/529
      device-aspect-ratio: 962/601 or 2221/1000
    
    0 讨论(0)
  • 2020-12-30 06:20

    The media queries that worked for me on Chrome on Nexus 7 were:

    @media only screen and (width : 600px) and (orientation: portrait) {
    
    }
    
    
    @media only screen and (width : 961px) and (orientation: landscape) {
    
    }
    
    0 讨论(0)
  • 2020-12-30 06:22

    I have a Nexus 7 and I have try your sricpt. The problem is that every browser have a different viewport. So it's complex to have a correct result.

    @media only screen and (device-width : 800px) and (orientation: portrait) {
        #device:after {
            content: "Nexus 7 - portrait - firefox";
        }
    }
    @media only screen and (width : 603px) and (orientation: portrait) {
        #device:after {
            content: "Nexus 7 - portrait - chrome";
        }
    }
    @media only screen and (device-width : 1280px) and (orientation: landscape) {
        #device:after {
            content: "Nexus 7 - landscape - firefox";
        }
    }
    @media only screen and (width : 966px) and (orientation: landscape) {
        #device:after {
            content: "Nexus 7 - landscape - chrome";
        }
    }
    

    I don't have time to make Opera.

    You can view the result here with your Nexus 7

    0 讨论(0)
  • 2020-12-30 06:23

    To specifically target you can use:

    @media only screen and (min-width : 600px) and (max-width : 603px) and (orientation: portrait) {
    //Your CSS Here
    }
    

    This will get the nexus 7 and if you have iPhone targetting media queries they will remain in tact.

    0 讨论(0)
  • 2020-12-30 06:23

    You should try using a mix of inches for screen sizes and px for density/space

    With this you can have a distinct layout for a galaxy nexus AND a nexus 7 without a bunch of lines for resolution!!

    // High end Android device
    @media  screen and (min-width: 600px) and (max-width: 5in)
    {
    
    }
    // nexus 7 and ipad mini
    @media  screen and (min-width: 7in) and (max-width: 9in)
    {
    
    }
    

    Here an article about this: http://ungeekautourdumonde.com/css3-tablette-desktop-mobile-la-guerre-des-media-queries/

    0 讨论(0)
提交回复
热议问题