“Best clearfix ever?”

前端 未结 5 2215
借酒劲吻你
借酒劲吻你 2021-02-06 18:12

I saw this rather different method for clearfix here: http://www.marcwatts.com.au/blog/best-clearfix-ever/

It proposes adding the following CSS code which automates clea

5条回答
  •  爱一瞬间的悲伤
    2021-02-06 19:03

    I've been clearing all divs globally for the past couple of years in my projects, and it has been working great for me. In approximately 95% of the cases where I use divs, clearfix has worked like a charm when applied to a site globally. There are certainly cases where a potential issue will arise, and I end up undoing the clearfix for any problematic divs. The CSS declarations I use are:

    div:after {
        clear: both;
        margin: 0;
        padding: 0;
        display: table;
        font-size: 0;
        line-height: 0;
        content: ' ';
        visibility: hidden;
        overflow: hidden;
        }
    div {
        *zoom: 1;
        }
    

提交回复
热议问题