Precise positioning: Display on hover

  1. Position: relative
  2. Precise positioning

Don’t forget about that review quote we hid earlier. Now that we know both hover and position, we can make the quote paragraph show up when a visitor hovers over one of the review links. We have the space for it on the left.

ul#menu ol li:hover p {

display: block;

margin-top: 0;

padding: 2%;

position: absolute;

top: 102%;

left: 2%;

border: solid .1em brown;

width: 90%;

}

By setting the top to 102%, we are aligning the top of the paragraph to the bottom of the menu: 100% of the menu’s height is its bottom. Another 2% gives us a little space.

image 21

And, again, remember that hovering only works in browsers where hovering makes sense.

  1. Position: relative
  2. Precise positioning