宽度,高度:
属性名称 | 作用 |
---|---|
width、height | 浏览器可视宽高 |
device-width | 设备屏幕宽度 |
device-height | 设备屏幕高度 |
浏览器宽度媒体查询:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
width: 500px;
height:200px;
border:1px solid #ccc;
}
@media screen and (min-width:500px) and (max-width:700px){
div{
background-color: red;
}
}
@media screen and (min-width:701px){
div{
background-color: blue;
}
}
</style>
</head>
<body>
<div>
</div>
</body>
</html>
注意:
@media screen and 语法: and两边必须有空格。