Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在桌面浏览器中工作的媒体查询,但在移动浏览器中不工作_Html_Css_Mobile_Media Queries - Fatal编程技术网

Html 在桌面浏览器中工作的媒体查询,但在移动浏览器中不工作

Html 在桌面浏览器中工作的媒体查询,但在移动浏览器中不工作,html,css,mobile,media-queries,Html,Css,Mobile,Media Queries,在5个主要的最新浏览器中都可以正常工作,但在任何移动设备上都不行,我不知道为什么 这是我的密码 /* Desktop */ @import url("desktop.css"); /* Small Phone */ @import url("smallMobile.css") only screen and (max-width:320px); /* Large Phone and small Tablet */ @import url("largeMobile-smallTablet.cs

在5个主要的最新浏览器中都可以正常工作,但在任何移动设备上都不行,我不知道为什么

这是我的密码

/* Desktop */
@import url("desktop.css");

/* Small Phone */
@import url("smallMobile.css") only screen and (max-width:320px);

/* Large Phone and small Tablet */
@import url("largeMobile-smallTablet.css") only screen and (min-width:321px) and (max-width:600px);
/*平板电脑和小型桌面*/ @仅导入url(“tablet smallDesktop.css”)屏幕和(最小宽度:601px)和(最大宽度:1120px)

试试看

@media only screen and (min-width:321px) and (max-width:600px) {
  @import url("largeMobile-smallTablet.css");
}


使用
设备宽度
,确保您知道要瞄准哪些手机;较新的iPhone具有不同的
设备像素比率
值,这些值会改变
设备宽度

以下是针对不同iPhone的媒体查询(请在此处查看更多常见维度):

对于iPad:

/* ----------- iPad 1 and 2 ----------- */
/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (-webkit-min-device-pixel-ratio: 1) {

}

/* ----------- iPad 3 and 4 ----------- */
/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (-webkit-min-device-pixel-ratio: 2) {

}
/* ----------- iPhone 4 and 4S ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2) {

}


/* ----------- iPhone 5 and 5S ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 568px)
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* ----------- iPhone 6 ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 667px) 
  and (-webkit-min-device-pixel-ratio: 2) { 

}


/* ----------- iPhone 6+ ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 414px) 
  and (max-device-width: 736px) 
  and (-webkit-min-device-pixel-ratio: 3) { 

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

}

/* ----------- iPad 3 and 4 ----------- */
/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (-webkit-min-device-pixel-ratio: 2) {

}