The desired effect is a centered yellow box with a red outline. Must be two seperate divs.
The "long story". I am working on a landing page editor that sometimes takes HTML from other sources. So I could have a "template" that might be centered including header/footer info, and then the editor I am working on would absolutely position on top of the template. The problem is that if the template is centered, then my top left point (for positioning) must match the top left point of the template. Thus it needs to hug it tight, and not expand 100%.
So I simplified the whole complication by saying, I have a centered block (yellow box) and I need an outer box to surround it. (red border div)
So ultimately, I need a centered yellow box with a red border. Two divs.
I changed the DOCTYPE to XHTML strict. No Change. I uploaded that one here
http://www.commadot.com/jq
Main Topics
Browse All Topics





by: VirusMinusPosted on 2007-04-25 at 16:37:12ID: 18978312
I'm not sure what exactly you're after,
px;margin: 0 auto"> px;margin: 0 auto">
Is it a centered div, with another div inside it taking up all the space? Is the inner div centered as well? Could you show a screenshot of what the desired layout is?
The doctype makes a big difference in browser and if they render to standards. Always try and use the strict DOCTYPE. This will go a fair way in correcting IE6's broken box model and other non-standard rendering of CSS.
and its semantically incorrect to have a block element such as a div inside any inline element, in your case a div forced as inline.
this with the strict doctype should work to get a centered div with another inside it taking up all the space (the effect is the same as 1 div with a border.. thats why i don't get what you're after)
<xmp>
Example E: Normal centered DIV with DIV inside
<div style="border: 1px solid red;width:100px;height:100
<div style="height: 100%; background: yellow;">
Text
</div>
</div>
</xmp>
<div style="border: 1px solid red;width:100px;height:100
<div style="height: 100%; background: yellow;">
Text
</div>
</div>