三星S7媒体查询

5

我正在尝试使用这些针对S7的媒体查询,但它不起作用。有其他建议吗?

@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 4) 
  and (orientation: portrait) {

/* Style */ 

}

2
不要使用特定设备的媒体查询,否则你会头痛。下面的答案很好。 - Marcos Pérez Gude
5个回答

12

我使用这个功能,到目前为止还没有出现问题。将所有内容添加到你的.css文件中。

/*
      Based on:
      1. http://stephen.io/mediaqueries
      2. https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
    */

    /* iPhone 6 in portrait & landscape */
    @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) {
      
    }

    /* iPhone 6 in landscape */
    @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : landscape) {
      
    }

    /* iPhone 6 in portrait */
    @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : portrait) {
      
    }

    /* iPhone 6 Plus in portrait & landscape */
    @media only screen 
    and (min-device-width : 414px) 
    and (max-device-width : 736px) {
      
    }

    /* iPhone 6 Plus in landscape */
    @media only screen 
    and (min-device-width : 414px) 
    and (max-device-width : 736px) 
    and (orientation : landscape) {
      
    }

    /* iPhone 6 Plus in portrait */
    @media only screen 
    and (min-device-width : 414px) 
    and (max-device-width : 736px) 
    and (orientation : portrait) {
      
    }

    /* iPhone 5 & 5S in portrait & landscape */
    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 568px) {
      
    }

    /* iPhone 5 & 5S in landscape */
    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 568px) 
    and (orientation : landscape) {
      
    }

    /* iPhone 5 & 5S in portrait */
    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 568px) 
    and (orientation : portrait) {
      
    }

    /* 
      iPhone 2G, 3G, 4, 4S Media Queries
      It's noteworthy that these media queries are also the same for iPod Touch generations 1-4.
    */

    /* iPhone 2G-4S in portrait & landscape */
    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 480px) {
      
    }

    /* iPhone 2G-4S in landscape */
    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 480px) 
    and (orientation : landscape) {
      
    }

    /* iPhone 2G-4S in portrait */
    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 480px) 
    and (orientation : portrait) {
      
    }

    /* iPad in portrait & landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px)  {
      
    }

    /* iPad in landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : landscape) {
      
    }

    /* iPad in portrait */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : portrait) {
      
    }

    /* Galaxy S3 portrait and landscape */
    @media screen 
      and (device-width: 320px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 2) {

    }

    /* Galaxy S3 portrait */
    @media screen 
      and (device-width: 320px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 2) 
      and (orientation: portrait) {

    }

    /* Galaxy S3 landscape */
    @media screen 
      and (device-width: 320px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 2) 
      and (orientation: landscape) {

    }

    /* Galaxy S4 portrait and landscape */
    @media screen 
      and (device-width: 320px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) {

    }

    /* Galaxy S4 portrait */
    @media screen 
      and (device-width: 320px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) 
      and (orientation: portrait) {

    }

    /* Galaxy S4 landscape */
    @media screen 
      and (device-width: 320px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) 
      and (orientation: landscape) {

    }

    /* Galaxy S5 portrait and landscape */
    @media screen 
      and (device-width: 360px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) {

    }

    /* Galaxy S5 portrait */
    @media screen 
      and (device-width: 360px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) 
      and (orientation: portrait) {

    }

    /* Galaxy S5 landscape */
    @media screen 
      and (device-width: 360px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) 
      and (orientation: landscape) {

    }

    /* HTC One portrait and landscape */
    @media screen 
      and (device-width: 360px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) {

    }

    /* HTC One portrait */
    @media screen 
      and (device-width: 360px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) 
      and (orientation: portrait) {

    }

    /* HTC One landscape */
    @media screen 
      and (device-width: 360px) 
      and (device-height: 640px) 
      and (-webkit-device-pixel-ratio: 3) 
      and (orientation: landscape) {

    }

    /*
      iPad 3 & 4 Media Queries
      If you're looking to target only 3rd and 4th generation Retina iPads 
      (or tablets with similar resolution) to add @2x graphics,
      or other features for the tablet's Retina display, use the following media queries.
    */

    /* Retina iPad in portrait & landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px)
    and (-webkit-min-device-pixel-ratio: 2) {
      
    }

    /* Retina iPad in landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : landscape)
    and (-webkit-min-device-pixel-ratio: 2) {
      
    }

    /* Retina iPad in portrait */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : portrait)
    and (-webkit-min-device-pixel-ratio: 2) {
      
    }

    /*
      iPad 1 & 2 Media Queries
      If you're looking to supply different graphics or choose different typography 
      for the lower resolution iPad display, the media queries below will work 
      like a charm in your responsive design!
    */

    /* iPad 1 & 2 in portrait & landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (-webkit-min-device-pixel-ratio: 1) {
      
    }

    /* iPad 1 & 2 in landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : landscape)
    and (-webkit-min-device-pixel-ratio: 1) {
      
    }

    /* iPad 1 & 2 in portrait */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : portrait) 
    and (-webkit-min-device-pixel-ratio: 1) {
      
    }

    /* iPad mini in portrait & landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px)
    and (-webkit-min-device-pixel-ratio: 1) {
      
    }

    /* iPad mini in landscape */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : landscape)
    and (-webkit-min-device-pixel-ratio: 1) {

    }

    /* iPad mini in portrait */
    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : portrait)
    and (-webkit-min-device-pixel-ratio: 1) {
      
    }

    /* Galaxy Tab 10.1 portrait and landscape */
    @media
      (min-device-width: 800px) 
      and (max-device-width: 1280px) {

    }

    /* Galaxy Tab 10.1 portrait */
    @media 
      (max-device-width: 800px) 
      and (orientation: portrait) { 

    }

    /* Galaxy Tab 10.1 landscape */
    @media 
      (max-device-width: 1280px) 
      and (orientation: landscape) { 

    }

    /* Asus Nexus 7 portrait and landscape */
    @media screen 
      and (device-width: 601px) 
      and (device-height: 906px) 
      and (-webkit-min-device-pixel-ratio: 1.331) 
      and (-webkit-max-device-pixel-ratio: 1.332) {

    }

    /* Asus Nexus 7 portrait */
    @media screen 
      and (device-width: 601px) 
      and (device-height: 906px) 
      and (-webkit-min-device-pixel-ratio: 1.331) 
      and (-webkit-max-device-pixel-ratio: 1.332) 
      and (orientation: portrait) {

    }

    /* Asus Nexus 7 landscape */
    @media screen 
      and (device-width: 601px) 
      and (device-height: 906px) 
      and (-webkit-min-device-pixel-ratio: 1.331) 
      and (-webkit-max-device-pixel-ratio: 1.332) 
      and (orientation: landscape) {

    }

    /* Kindle Fire HD 7" portrait and landscape */
    @media only screen 
      and (min-device-width: 800px) 
      and (max-device-width: 1280px) 
      and (-webkit-min-device-pixel-ratio: 1.5) {

    }

    /* Kindle Fire HD 7" portrait */
    @media only screen 
      and (min-device-width: 800px) 
      and (max-device-width: 1280px) 
      and (-webkit-min-device-pixel-ratio: 1.5) 
      and (orientation: portrait) {
        
    }

    /* Kindle Fire HD 7" landscape */
    @media only screen 
      and (min-device-width: 800px) 
      and (max-device-width: 1280px) 
      and (-webkit-min-device-pixel-ratio: 1.5) 
      and (orientation: landscape) {

    }

    /* Kindle Fire HD 8.9" portrait and landscape */
    @media only screen 
      and (min-device-width: 1200px) 
      and (max-device-width: 1600px) 
      and (-webkit-min-device-pixel-ratio: 1.5) {

    }

    /* Kindle Fire HD 8.9" portrait */
    @media only screen 
      and (min-device-width: 1200px) 
      and (max-device-width: 1600px) 
      and (-webkit-min-device-pixel-ratio: 1.5) 
      and (orientation: portrait) {
        
    }

    /* Kindle Fire HD 8.9" landscape */
    @media only screen 
      and (min-device-width: 1200px) 
      and (max-device-width: 1600px) 
      and (-webkit-min-device-pixel-ratio: 1.5) 
      and (orientation: landscape) {

    }

    /* Laptops non-retina screens */
    @media screen 
      and (min-device-width: 1200px) 
      and (max-device-width: 1600px) 
      and (-webkit-min-device-pixel-ratio: 1) {
        
    }

    /* Laptops retina screens */
    @media screen 
      and (min-device-width: 1200px) 
      and (max-device-width: 1600px) 
      and (-webkit-min-device-pixel-ratio: 2)
      and (min-resolution: 192dpi) {
        
    }

    /* Apple Watch */
    @media
      (max-device-width: 42mm)
      and (min-device-width: 38mm) { 

    }

    /* Moto 360 Watch */
    @media 
      (max-device-width: 218px)
      and (max-device-height: 281px) { 

    }


谢谢你们的回答! - Liron Paryente
3
不回答问题。原帖问的是三星Galaxy S7。 - Bastien Bastiens
我发布的媒体查询CSS已经覆盖了这一点,并且考虑到这个问题一个月前就已经得到解答,原始帖子也没有更多的问题,我认为它起作用了。 - mlegg
我同意Bastien的观点。你的回答中没有s7,它只到s5。 - user2903379
https://mydevice.io/devices/ 显示CSS宽度和高度为360x640像素,像素比为4,即-webkit-min-device-pixel-ratio: 3 - Gianfranco P.

6

可能有点晚了,但这是我在S7和S8上使用的方法

/*Galaxy S7 and S8 */
@media only screen and (min-device-width : 360px) and (max-device-width : 640px){


}

4
将以下内容添加到您的<head>标签中:
<meta name="viewport" content="width=device-width, initial-scale=1">

这将告诉代码查看设备视口的实际像素宽度,而不是分辨率值。

3

我刚遇到了同样的问题。
在我的设备上进行了一些测试后,我发现设备像素比为3是针对我的Galaxy S7的。

此外,如果你想要将某物与折页对齐,我发现地址栏高度为75px。

这是在Chrome浏览器中发现的。


1

我使用了这个,它起作用了

/* samsung s7 portrait */
@media 
    (-webkit-min-device-pixel-ratio: 3)
    and (min-resolution: 192dpi)and max-width:640px){

}

/* samsung s7 landscape*/
@media 
    (-webkit-min-device-pixel-ratio: 3) 
    and (min-resolution: 192dpi){

}

在提问/回答问题时,请查看输入字段旁边的黄色块。它会显示如何格式化您的文本。请编辑您的答案并适当地格式化代码。 - Frits

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接