cboy
cboy

Reputation: 179

CSS :hover div elements

My css: .sec-hover :hover {background:pink;}

My div:<div class="sec-hover"><h2>heading</h2><p>paragraph</p></div>

With this code, the whole div does not hover in pink. On hover the h2 and p elements hover pink separately. How do I get the whole div to hover pink?

codepen: [1]: http://codepen.io/cboy/pen/GWgOGa

Upvotes: 2

Views: 3711

Answers (3)

Momin
Momin

Reputation: 3320

Try This ! Used proper syntax ;

.sec-hover:hover{
background:pink;
color:white;
}
<div class="sec-hover">
  <h2>heading</h2>
  <p>paragraph</p>
</div>

Upvotes: 0

neophyte
neophyte

Reputation: 6626

Use background-color

.sec-hover:hover{
background-color: pink 
}
<div class="sec-hover"><h2>heading</h2><p>paragraph</p></div>

Upvotes: 1

Nayana_Das
Nayana_Das

Reputation: 1817

No space before colon : , Try this :

.sec-hover:hover{
background: pink 
}

Upvotes: 5

Related Questions