guavo
guavo

Reputation: 13

How to change whole div background with hover

How can I change the background of my div interestBTN with css?

My 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>

Thank in advance!

Upvotes: 1

Views: 62

Answers (2)

Shubham Gupta
Shubham Gupta

Reputation: 11

.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>

Upvotes: 0

Pete
Pete

Reputation: 58422

All you need to do is remove the space before the :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>

Upvotes: 2

Related Questions