I'm facing an issue with two nested divs, where the #messages
div is inside the #mainContent
div. The position of the #messages
div should be 0px from the top of its parent, but when I add an unordered list inside it, the whole div shifts down by a few pixels.
Setting margin-top:0px;
on the ul
element resolves the issue, however, I need the ul to have a margin-top:10px;
from its #messages
parent. But adding margin-top:10px;
once again pushes the #messages
div down by 10px from #mainContent
.
I would appreciate an explanation of why this behavior occurs and a clean solution to address this problem.
Your assistance is greatly appreciated, and here is the link to the jsfiddle
: