Makaze

:hover demo

Apr 18th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.01 KB | None | 0 0
  1. <style>
  2. body {
  3. margin: 100px;
  4. }
  5.  
  6. div {
  7. border: 3px solid #333;
  8. }
  9.  
  10. #parent1, #parent2, #parent3 {
  11. display: inline-block;
  12. position: relative;
  13. width: 200px;
  14. background-color: #55f;
  15. padding: 10px;
  16. }
  17.  
  18. #parent1 div, #parent2 div, #parent3 div {
  19. background-color: #0f0;
  20. height: 30px;
  21. margin-top: 50px;
  22. padding: 5px;
  23. }
  24.  
  25. #parent1:hover {
  26. background-color: #f00;
  27. }
  28.  
  29. #parent2 div:hover {
  30. background-color: #f00;
  31. }
  32.  
  33. #parent3:hover div {
  34. background-color: #f00;
  35. }
  36. </style>
  37.  
  38. <div id="parent1">
  39. <strong>#parent1:hover</strong>
  40. <br /><br />
  41. Affects the style of the parent when you hover over the parent (or anything in the parent).
  42. <div>Child</div>
  43. </div>
  44.  
  45. <div id="parent2">
  46. <strong>#parent2 div:hover</strong>
  47. <br /><br />
  48. Affects the style of the child when you hover over the child.
  49. <div>Child</div>
  50. </div>
  51.  
  52. <div id="parent3">
  53. <strong>#parent3:hover div</strong>
  54. <br /><br />
  55. Affects the style of the child when you hover over the parent (or anything in the parent).
  56. <div>Child</div>
  57. </div>
Advertisement
Add Comment
Please, Sign In to add comment