Jump to content
MakeWebGames

CSS parent child divs and margins


Gollimari

Recommended Posts

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...