为不同尺寸的设备设置不同的 CSS 样式规则的媒体查询
cssweb developmentfront end technology更新于 2025/3/20 2:20:17
要为不同的 CSS 样式规则设置媒体查询,您可以尝试运行以下代码 −
示例
<html>
<head>
<style>
body {
background-color: lightpink;
}
@media screen and (max-width: 420px) {
body {
background-color: lightblue;
}
}
</style>
</head>
<body>
<p>If screen size is less than 420px, then it will show lightblue color, or else it will show light pink color</p>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

