先直接上代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>demo</title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
}
div {
width: 800px;
height: 800px;
background-color: skyblue
}
/**
* 先用width试试
*/
@media only screen and (width: 375px) {
div {
width: 50px;
height: 50px;
background-color: red
}
}
/**
* 再用max-width试试
*/
/* @media only screen and (max-width: 900px) {
div {
width: 50px;
height: 50px;
background-color: red
}
}*/
</style>
</head>
<body>
<div></div>
</body>
</html>
meta和@media匹配使用