我想在我的代码中添加一个 CSS 按钮,但按钮的背景颜色没有改变。
这是我的按钮 CSS 代码:
.button {
background-color: red;
border: solid;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline;
font-size: 16px;
-moz-appearance: button;
-webkit-appearance: button;
text-decoration: none;
}
这是我目前拥有的 HTML 代码:
<div>
<a href="names.html" class="button">Click here</a>
</div>
无论我设置什么,按钮的背景都保持标准的白色background-color
。这是当前按钮,但我想更改背景。
这正是您的代码。你如何看到它的工作原理。我认为在您的项目中是另一个覆盖您的背景颜色的 CSS。您可以使用开发人员工具 (F12) 来检查 CSS 的哪一部分负责背景颜色。
chrome 开发工具(检查 html)
chrome 开发工具(检查 css)
.button {
background-color: red;
border: solid;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline;
font-size: 16px;
-moz-appearance: button;
-webkit-appearance: button;
text-decoration: none;
}
<div>
<a href="names.html" class="button">Click here</a>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句