开发者

height of wrapper div to inside floated items?

开发者 https://www.devze.com 2023-04-06 23:27 出处:网络
I have a div \'a\' ( simple div) and div \'b\' which is float:left; I was wondering what is the correct method to set the height of 开发者_高级运维div \'a\' to be a perfect wrapper for div \'b\' ( i

I have a div 'a' ( simple div)

and div 'b' which is float:left;

I was wondering what is the correct method to set the height of 开发者_高级运维div 'a' to be a perfect wrapper for div 'b' ( in terms of height).

height of wrapper div to inside floated items?

i know there are some options :

1)set 'a' : overflow:hidden ( it works).

2)set at the end of 'b' div with 'clear':both

  • ) i would love to know more options ( besides fixed height to div 'a'...)

  • ) and of course , what is the better way.


@Royi Namir; there others mades like clearfix like this

css:

.clearfix:after {
    display: block;
    content: " ";
    clear: both;
    }

as per the better way clearfix & overflow:hidden both are better because you no need to write any extra markup in your html for every element.

0

精彩评论

暂无评论...
验证码 换一张
取 消