hr clear vs div clear. Which is better?

前端 未结 4 870
栀梦
栀梦 2021-01-20 18:18

This is a general question and something that dawned on me and seemed to make sense. I have seen many people use clearing divs

and
4条回答
  •  心在旅途
    2021-01-20 19:12

    Both methods are old fashioned. The latest "trick" is to use overflow property for the container of float elements.

    If for example you have:

    text here
    text here

    with float class float:left then it's better to use overflow:hidden or overflow:auto than

    or the hr method.

    Demo: http://jsfiddle.net/vALSL/

    Read more here: http://www.quirksmode.org/css/clearing.html

提交回复
热议问题