使用css屏幕自适应
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color:lightgreen;
}
@media screen and (max-width: 400px) {
body {
background-color:lightblue;
}
}
</style>
</head>
<body>
<p>重置浏览器查看大小。当浏览器窗口的宽度小于 400 像素时,背景颜色会变成淡蓝,否则是淡绿色。</p>
<SCRIPT>
</SCRIPT>
</body>
</html>