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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.