html与css代码:
<!DOCTYPE html>
<html>
<head>
<!-- 设置编码格式 -->
<meta charset="utf-8">
<!-- 手机,移动端开发,需要加的meta标签 -->
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width">
<style>
body {
background-color: lightgreen;
}
@media screen and (max-width: 500px) {
body {
background-color: lightblue;
/*禁止手机浏览器下拉刷新*/
overflow:hidden;
}
}
</style>
</head>
<body>
<h2>当浏览器窗口的宽度小于 500 像素时,背景颜色会变成淡蓝,否则是淡绿色。</h2>
</body>
</html>