How to deal with floated elements?

前端 未结 3 1218
南旧
南旧 2021-01-25 15:42

If there are floated elements in a parent element, they parent element looses its shape or has no height. How to deal with this problem?

Thanks

相关标签:
3条回答
  • 2021-01-25 16:24

    The solution to that is using clearfix class.

    0 讨论(0)
  • 2021-01-25 16:24

    Basically you have to wrap floated elements with a block that has a clearfix hack applied. Read more here: http://www.webtoolkit.info/css-clearfix.html

    For IE<7 you would also use zoom:1;

    0 讨论(0)
  • 2021-01-25 16:25

    On the parent, do a:

     style="overflow: auto"
    
    0 讨论(0)
提交回复
热议问题