Why does order of float div and non-float div matter only in some cases?

后端 未结 2 1699
面向向阳花
面向向阳花 2021-01-18 12:00

I have a similar problem as CSS Auto Margin pushing down other elements: A right floating sidebar gets pushed down below the main non-floating content div. The answer propo

相关标签:
2条回答
  • 2021-01-18 12:31

    the reason the one you linked works is because the other columns are also floated

    0 讨论(0)
  • 2021-01-18 12:40

    The reason this works is because your containing element has no height. When you have nothing but floated elements inside a containing element, it will collapse to 0 height. If you were, for example, to add overflow: hidden; to #fluidColumnContainer, it would act as a clear-fix, expanding the container to contain the floated elements. Then you would see the right-floated element drop down again.

    0 讨论(0)
提交回复
热议问题