Possible Duplicate:
Margin on child element moves parent element
I have a parent div that contains a child div. Parent
is the first element in the body, with no particular CSS style. When I set
.child {
margin-top: 10px;
}
the end result is that top of child
is still aligned with parent
. Instead of child
being shifted for 10px downwards, my parent moves 10px down.
I found that adding padding to parent
can work but I've read that this is not the way to solve problem. Why? If I want margin-right
I can do padding-right
on parent
, likewise if I want margin-top
I can also do padding-top
and get the correct result.
In margin on child element moves parent element someone said:
What if you want a top-margin...? Not really a solution. This isn't really a solution if a top margin is required.
What is he trying to say? Please explain.