几个典型的应用例子
@media screen and (device-width:1024px){ … }
@import url(example.css) screen and (min-device-width:800px);
<link media="screen and (min-device-width:300px) and (max-device-width:900px)" rel="stylesheet" href="example.css" />
应用例子演示
<!doctype html>
<html>
<head>
<title>Test media query of device</title>
<style>
@media screen and (device-width:600px){
body{background-color:green;}
}
</style>
</head>
<body>
<h1>Test device query</h1>
</body>
</html>
- 当设备的屏幕宽度为600px的时候,页面的背景颜色为绿色的