Answer the question
In order to leave comments, you need to log in
Why is the div being cut off?
It seems to me that the question is elementary, I just do not know some basics. Please explain the behaviour.
Here is the simplest html code:
<div id="aa">
<div id="bb">bb</div>
</div>
#aa {background-color: #555; border: solid 2px red;}
#bb {background-color: #ccc; height: 100px; width: 50%; margin: 50px;}
#aa
a property padding
or enter some text.
Answer the question
In order to leave comments, you need to log in
Block bb states that any block must be at least 50 pixels away from it. This does not apply to the parent block. For padding from the parent block boundaries, the parent must have padding jsfiddle.net/JyHCd/ or the parent block must limit the interaction of nested blocks beyond its borders (overflow jsfiddle.net/JyHCd/1/ ). In some specific cases, this option is also acceptable: jsfiddle.net/JyHCd/2/
Also, as an option, you can add indents to the parent element, for example:
padding: 1px 0;
margin: 49px 50px;
This is how it should be - www.w3.org/TR/CSS21/box.html#collapsing-margins . Everything would be fine, but in Ie6-7, depending on the haslayout of the inner / outer blocks, this effect behaves completely differently, so you need to get rid of it. Replace margin with padding OR Add 1px top and bottom padding to the outer box.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question