Gollimari Posted August 25, 2009 Posted August 25, 2009 When I have a parent div where the only content of that div is a child div, the child div's margins and margins of the elements in the child div don't work correctly. so <div id="outer"> <div id="inner"> <h2>inner div title</h2> </div> </div> When I set a margin on the inner div, it moves the entire box down, including the outer div. If I put a margin on the H2, it also moves the entire box including the outer div. This is the same when replacing the H2 for a . If I have a border on the inner div, that fixes it and the H2 margin moves around within the inner div and outer stays where it is, and margins on the inner div work as they should. If I put plain textual content in either the inner or outer div (I tried a letter "a"), that also fixes it and the inner div and elements in the inner div then obey as they should. What's the way to resolve this without using one of the above I mentioned as they are no good. Windows 7 - comes with free keyboard and noose! ---------------------------------- naruto games playstation 2 games Quote
POG1 Posted August 25, 2009 Posted August 25, 2009 Re: CSS parent child divs and margins try setting a padding, most of the time it will cancel out child element margins going outside. or you could try.. div.inner h2 { margin:0; } Quote
Floydian Posted August 26, 2009 Posted August 26, 2009 Re: CSS parent child divs and margins What does this have to do with javascript? Quote
Haunted Dawg Posted August 26, 2009 Posted August 26, 2009 Re: CSS parent child divs and margins I think it's a bot? Quote
Faz` Posted August 26, 2009 Posted August 26, 2009 Re: CSS parent child divs and margins Windows 7 - comes with free keyboard and noose! ---------------------------------- naruto games playstation 2 games Looks like it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.