2

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

3 Answers 3

5

No space before colon : , Try this :

.sec-hover:hover{
background: pink 
}
Sign up to request clarification or add additional context in comments.

Comments

1

Use background-color

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

Comments

0

Try This ! Used proper syntax ;

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.