CSS CSS Layout Basics Page Layout with the Float Property Clearing and Containing Floats

Siddharth Pande
Siddharth Pande
9,046 Points

using floats and clearfix

instead of using clearfix to ajust the header to its proper height why can we use position: fixed?

2 Answers

Jacob Jackson
seal-mask
.a{fill-rule:evenodd;}techdegree
Jacob Jackson
UX Design Techdegree Student 7,806 Points

Oh, I misunderstood.

The answer is that technically you could. But for the same reason that the video suggests not giving a fixed height, I would suggest against a fixed position. When you use an option like this in this situation, you could get away with it, but you limit the flexibility for your page.

You should always code with flexibility in mind so you can easily make changes in the future without having to force anything into position. A little extra work up front saves you a lot of time down the road.

Siddharth Pande
Siddharth Pande
9,046 Points

Thanks again, you cleared my doubt.

Jacob Jackson
seal-mask
.a{fill-rule:evenodd;}techdegree
Jacob Jackson
UX Design Techdegree Student 7,806 Points

Hey Siddharth!

The "fixed" position will actually "fix" the header to a specific place on your screen, relative the viewport itself. From there it will not move.

Think of nav bars that always remain at the top of the page while you're scrolling for example.

The give a great explanation and a viewable example at w3schools here:

https://www.w3schools.com/Css/css_positioning.asp

Hope this helps! -Jake

Siddharth Pande
Siddharth Pande
9,046 Points

Thank you for answering but I wanted to know that instead of using clearfix why dont we use position: fixed to adjust the collapsed height.