CSS参考手册
媒体查询 | Media Queries
设备宽度 | @media.device-width
弃用
该功能已从Web标准中删除。尽管一些浏览器可能仍然支持它,但它正在被丢弃。避免使用它并尽可能更新现有的代码; 请参阅本页面底部的兼容性表格来指导您的决定。请注意,此功能可能随时停止工作。
device-width
CSS @media
媒体功能可基于所述输出设备的呈现表面宽度,用于应用样式。
语法
该device-width
功能被指定为一个<length>
值。这是一个范围功能,也就是说,您也可以使用前缀min-device-width
和max-device-width
变量分别查询最小值和最大值。
例子
此HTML适用于小于800像素的设备的特殊样式表。
<link rel="stylesheet" media="screen and (max-device-width: 799px)" href="http://foo.bar.com/narrow-styles.css" />
规范
Specification |
Status |
Comment |
---|---|---|
Media Queries Level 4The definition of 'device-width' in that specification. |
Working Draft |
Deprecated in Media Queries Level 4. |
Media QueriesThe definition of 'device-width' in that specification. |
Recommendation |
Initial definition. |
浏览器兼容性
Feature |
Chrome |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|
Basic support |
? |
? |
? |
? |
? |
Feature |
Android |
Firefox Mobile (Gecko) |
IE Mobile |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|
Basic support |
? |
? |
? |
? |
? |
媒体查询 | Media Queries相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。