如何用悬停改变整个div背景

时间:2016-07-21 12:10:54

标签: html css hover

如何使用css更改div interestBTN的背景?

我的css:

.interestBTN {
  width: 50%;
  height: 35px;
  line-height: 35px;
  border-color: #ACED52;
  border-radius: 10px;
  font-size: 18px;
  color: black;
  text-align: center;
  margin: auto;
  margin-bottom: 30px;
  background-color: #ACED52;
}

div.interestBTN :hover {
  background-color: black;
  color: #ACED52;

}

HTML:

<a href="#"><div class="interestBTN"><strong>Open</strong></div></a>

提前感谢!

2 个答案:

答案 0 :(得分:2)

您需要做的就是删除:hover

之前的空格

.interestBTN {
  width: 50%;
  height: 35px;
  line-height: 35px;
  border-color: #ACED52;
  border-radius: 10px;
  font-size: 18px;
  color: black;
  text-align: center;
  margin: auto;
  margin-bottom: 30px;
  background-color: #ACED52;
}

div.interestBTN:hover {
  background-color: black;
  color: #ACED52;

}
<a href="#"><div class="interestBTN"><strong>Open</strong></div></a>

答案 1 :(得分:0)

.interestBTN {
  width: 50%;
  height: 35px;
  line-height: 35px;
  border-color: #ACED52;
  border-radius: 10px;
  font-size: 18px;
  color: black;
  text-align: center;
  margin: auto;
  margin-bottom: 30px;
  background-color: #ACED52;
}

div.interestBTN:hover {
  background-color: black;
  color: #ACED52;

}
<a href="#"><div class="interestBTN"><strong>Open</strong></div></a>