s.singh s.singh - 27 days ago 19
jQuery Question

why only height is adjustable of parent div if child div is resizeable?

I am new in html development . I sharing my simple code which have two div . one div is parent div and second div is it's child div .So now problem is that when I resizing child div only height is adjustable but when I resizing chid div to right side width of parent div not adjustable but I want it . So please anyone help me . following is my code :



<div style='border:1px solid;padding:20px;width:auto;height:auto;'>
<div style="resize: both;overflow:auto;border:1px solid;width:500px;height:200px;"/>
</div>




Answer

You just have to use display: inline-block.

.first {
  border:1px solid;
  padding:20px;
  width:auto;
  height:auto;
  display: inline-block;
}
.second {
  resize: both;
  overflow:auto;
  border:1px solid;
  width:500px;
  height:200px;
}
<div class="first">
 
<div class="second"></div>

</div><!-- /.first -->