Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

height of wrapper div to inside floated items?

Tags:

html

css

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).

enter image description here

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.

like image 627
Royi Namir Avatar asked Dec 31 '25 08:12

Royi Namir


1 Answers

@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.

like image 185
sandeep Avatar answered Jan 01 '26 23:01

sandeep