Html CSS3媒体查询不工作
我在我的网站上使用以下媒体查询Html CSS3媒体查询不工作,html,css,media-queries,Html,Css,Media Queries,我在我的网站上使用以下媒体查询 <link rel="stylesheet" href="web.css" media="only screen and (min-device-width : 1025px)" /> <link rel="stylesheet" href="ipad.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1024px)" /> 我
<link rel="stylesheet" href="web.css" media="only screen and (min-device-width : 1025px)" />
<link rel="stylesheet" href="ipad.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1024px)" />
我在这里的目的是为不同的设备提供不同的样式表。(目前我只想支持台式机和iPad)
但当我使用Firefox(版本8)或Chrome(版本15.0.874.106)在桌面上加载网站时,它会同时下载CSS文件(web.CSS和ipad.CSS)
我不太确定我的代码出了什么问题。有人能帮我吗。这可能不起作用,但请尝试将值调低一个数字:
<link rel="stylesheet" href="web.css" media="only screen and (min-device-width : 1024px)" />
<link rel="stylesheet" href="ipad.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1023px)"
它可能不起作用,但请尝试将值向下更改一个数字:
<link rel="stylesheet" href="web.css" media="only screen and (min-device-width : 1024px)" />
<link rel="stylesheet" href="ipad.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1023px)"
对于桌面
您必须编写最小宽度
,而不是最小设备
,如下所示:
<link rel="stylesheet" href="web.css" media="only screen and (min-width : 1025px)" />
<link rel="stylesheet" href="ipad.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1024px)" />
对于桌面
您必须编写最小宽度
,而不是最小设备
,如下所示:
<link rel="stylesheet" href="web.css" media="only screen and (min-width : 1025px)" />
<link rel="stylesheet" href="ipad.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1024px)" />
支持使用媒体查询的浏览器将下载所有样式表,无论需要显示哪个样式表
这些查询将根据分辨率(而不是设备)为您提供两个不同的布局句柄,但两个样式表都将始终下载
media="screen and (min-width: 768px) and (max-width: 1024px)"
media="screen and (min-width: 1025px)"
支持使用媒体查询的浏览器将下载所有样式表,无论需要显示哪一个
这些查询将根据分辨率(而不是设备)为您提供两个不同的布局句柄,但两个样式表都将始终下载
media="screen and (min-width: 768px) and (max-width: 1024px)"
media="screen and (min-width: 1025px)"
这里的问题是,在桌面上,它正在下载两个css文件。我想它不应该在桌面和viceversa上下载ipad.css。我的假设是错误的吗?它不会同时下载两个css文件,因为min width指的是页面的屏幕大小,min device width表示它在iphone和IPA等设备中打开时处于活动状态。这篇文章提供了更多信息。这里的问题是,在桌面上,它同时下载了两个css文件。我想它不应该在桌面和viceversa上下载ipad.css。我的假设是错误的吗?它不会同时下载两个css文件,因为min width指的是页面的屏幕大小,min device width指的是当它在iphone和IPA等设备中打开时它是活动的。更多信息,请阅读本文