Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto width for floated div

here is my code

<div class='content'>
  <div class='div1'>content</div>
  <div class='div2'>content</div>
</div>
.content { width:300px;}
.div1 { float:left;width:200px;}
.div2 { float:left;width:100px;}

in some case I need to set display:none for div2. is it possible to set .div1 width to full-size of .content ( 300px )

like image 519
Mironline Avatar asked Aug 26 '26 17:08

Mironline


1 Answers

Reorder your divs, and use overflow: hidden:

<div class='content'>
  <div class='div2'>content 2</div>
  <div class='div1'>content 1</div>
</div>
.content { width:300px; overflow: hidden;}
.div1 { overflow: hidden;}
.div2 { float:left; width:100px;}
like image 77
Eric Avatar answered Aug 29 '26 06:08

Eric



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!