Using fixed positioning for the nav bar

Let's change the nav bar's position property from absolute to fixed and take a look at the result:

nav {  background-color: #fff;  position: fixed;}

Following is the output of the preceding code:

The fixed value, such as relative, still acts like a coordinate system for any absolutely positioned child or descendant elements, but it also has some superpowers. Right now, those superpowers are totally breaking our nav. Here's the issue: position: relative still keeps its block-element qualities, while position: fixed loses a lot of those block qualities when it's removed from the normal flow, and the nav ...

Get Mastering CSS now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.