【发布时间】:2022-08-08 13:45:02
【问题描述】:
我目前正在为大学项目创建一个网站。因此,我想根据屏幕尺寸(针对移动用户)更改视图。
因此,我想更改一些我已经在相关类中指定的属性,但似乎这是不可能的。
为了说明问题,我创建了这两个按钮。 Button 1 的颜色由 background-color: blue 指定,如果尺寸小于 600 像素,则将其更改为红色,而 Button 2 的颜色未指定。
当您现在更改 Screen-size 时,您会看到只有 Button 2 的颜色会被更改。
所以我的问题是:是否可以更改已经指定的属性,如果可以,如何更改?
先感谢您!
@media screen and (max-width: 600px) {
.button_one {
background-color: red;
}
.button_two {
background-color: green;
}
}
.button_one {
background-color: blue;
}
</head>
<body>
<div>
<button class=\"button_one\"> Button 1 </button>
<button class=\"button_two\"> Button 2 </button>
</div>
</body>
</html>