【发布时间】:2019-02-06 01:45:26
【问题描述】:
我正在尝试在单击按钮后更改按钮的背景颜色(并可能使您无法再次单击它),但不知道如何更改颜色。我只想为此使用 HTML 和 CSS。我该怎么做?
body {
background-color: white;
}
.button {
font-family: "Arial", sans-serif;
background-color: black;
border: 10px dashed white;
color: white;
font-size: 30px;
text-align: center;
line-height: 0;
cursor:pointer;
border-radius: 8px;
height:200px;
width:400px;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
}
.button:visited{
background-image:none;
background-color: red;
font-size: 35px;
border: 10px dashed black;
color: black;
}
.button:hover{
background-image:none;
background-color: white;
font-size: 35px;
border: 10px dashed black;
color: black;
}
<button class="button" type="button" onclick="onClick()">Button</button>
【问题讨论】: