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

Zoe Campbell
Zoe Campbell
6,288 Points

Why does clearfix only work on my browser is if put it at the top of the media query and not the bottom?

Why does clearfix only work on my browser is if put it at the top of the media query and not the bottom?

3 Answers

Steven Parker
Steven Parker
204,019 Points

The "cascade" of CSS means that when settings have the same specificity, the ones that come last take precedence. This is why media queries would normally be placed after other code, so when their conditions apply they will override the other settings.

For a more specific analysis of what is happening in your particular example, you would need to show your code (formatted for markdown) here. Better yet, you could make a snapshot of your workspace and post the link to it here.

Zoe Campbell
Zoe Campbell
6,288 Points

That makes sense, i ask only because the tutor states to add the clearfix to the bottom of the media query on this video. https://w.trhou.se/ei0h5anrao

Steven Parker
Steven Parker
204,019 Points

That link was for your code (snapshot), not the video.

But I tried moving the clearfix to the bottom of the media query, and I did not see any difference in the displayed page. None of the properties set in it conflict with any others in the query, so I would not expect the position to matter.

Did you perhaps place it at the bottom of the file instead of the bottom of the media query the first time?