How to match height of floating sibling divs

后端 未结 5 556
醉酒成梦
醉酒成梦 2021-01-27 04:46

I have the following situation: http://jsfiddle.net/F3SqM/2/

I have two columns, I only know of the height of columnB. Both columns are floating, and I want columnA to m

5条回答
  •  既然无缘
    2021-01-27 04:57

    Personally I like the equal height columns from www.ejeliot.com

    http://jsfiddle.net/spacebeers/s8uLG/3/

    You set your container up with overflow set to hidden, then on each div add negative margin-bottom and equal positive padding-bottom.

    #container { overflow: hidden; }
    #container div { float: left; background: #ccc; width: 200px; margin-bottom: -2000px; padding-bottom: 2000px; }
    #container .col2 { background: #eee; }
    
    

    Content 1

    Content 2

    Content 2

    Content 2

    Content 2

    Faux Columns is also good and probably easier to set up but if you're really dead against using an image this is a pretty good method.

提交回复
热议问题