Rakesh
Rakesh

Reputation: 2790

div height is not growing according to content size

Hi I have a dynamic content $search_results and I am trying to display It inside a <div>. but the problem is the the height of the <div> is not increasing according to the content size. $search_results is a tabled content like <table><tr><td>Values</td></tr></table>

and here is the code.

<div  style="background:#CCC;">
<div style="height:500px;width:1000px;margin:auto;padding-top:20px;">
<div style="width:200px;float:left; background:#666;color:white;">
<form name="SearchForm" action="" method="post">
<ul class="SearchList">
<li class="firstlist">Search</li>

<li>
   <input  type="text"  class="text_medium" value="Keywords" name="KeywordsTextBox" onblur="if(this.value=='') this.value='Keywords'" onFocus="if(this.value =='Keywords' ) this.value=''" >
</li>

<li>
  <select name="SearchValues" class="select_medium">
     <option value="Search1">Search option 1</option>
     <option value="Search1">Search option 2</option>
     <option value="Search1">Search option 3</option>
     <option value="Search1">Search option 4</option>
  </select>
</li>

  <input type='submit' name='SearchButton' class='Small_Button'  value='Search'>
</li>

</ul>
</form>
</div>
<div style="width:800px;float:right; background:#C69;">
<form name="ResultForm" method="post" action="">
<?php 

//$serachObj =  new Search()

//$search_results = $serachObj->search();

echo $search_results; 
?>
</form>
</div>
</div>
</div>

I have tried style="min-height:500px;" but its not working. Any suggestions ?.

Upvotes: 2

Views: 4459

Answers (3)

sandeep
sandeep

Reputation: 92803

There is float in your the child DIV's. So, you have to clear the it's parent. Define overflow:hidden to the parent DIV. For example write like this:

<div style="overflow:hidden;min-height:500;width:1000px;margin:auto;padding-top:20px;">
 <div style="float:left"></div>
 <div style="float:left"></div>
</div>

UPDATED

<div style="min-height:500;width:1000px;margin:auto;padding-top:20px;">
     <div style="float:left"></div>
     <div style="float:left"></div>
     <div style="clear:both"></div>
</div>

Upvotes: 4

Vinoth Babu
Vinoth Babu

Reputation: 6852

Give div height as auto.

height:auto;

Upvotes: 1

Sowmya
Sowmya

Reputation: 26969

Add overflow:auto to the parent div

DEMO

Upvotes: 1

Related Questions