shaunthomson
07-31-2012, 06:19 AM
Gidday
I have a main container div (#mainContainer), which contains another container div (#returned), that has HTML retrieved from php via AJAX displayed in it. The problem is that #returned is over-running the border of #mainContainer.
I notice that giving #mainContainer a left float fixes the problem, but I want it to be centered, not aligned left.
How do I make #mainContainer adjust to the height of #returned? Is it a matter of having a third div to contain the other two, and float this new one left, or is there a better way to do this?
CSS (display is 'none' as this div is shown when a button is clicked):
.mainContainer { background-color:#252525; display:none; border:solid #555; border-width:thin; padding:8px; color:#fff; height:auto; margin-left:auto; margin-right:auto; width:294px; }
html:
<div class="mainContainer">
some text in here
<div id="returned" style="width:100%; background-color:#0F0; height:auto; float:left; display:block;"></div>
</div>
Thanks for your help.
I have a main container div (#mainContainer), which contains another container div (#returned), that has HTML retrieved from php via AJAX displayed in it. The problem is that #returned is over-running the border of #mainContainer.
I notice that giving #mainContainer a left float fixes the problem, but I want it to be centered, not aligned left.
How do I make #mainContainer adjust to the height of #returned? Is it a matter of having a third div to contain the other two, and float this new one left, or is there a better way to do this?
CSS (display is 'none' as this div is shown when a button is clicked):
.mainContainer { background-color:#252525; display:none; border:solid #555; border-width:thin; padding:8px; color:#fff; height:auto; margin-left:auto; margin-right:auto; width:294px; }
html:
<div class="mainContainer">
some text in here
<div id="returned" style="width:100%; background-color:#0F0; height:auto; float:left; display:block;"></div>
</div>
Thanks for your help.