About the use of percentage:
As they said, it refers to the upper block, but has to take some care, because the reference measure is the first upper block WHICH HAS AN ESTABLISHED MEASURE, that is, if the immediately preceding layer FOR A BLOCK does not have a valid measure, the percentage will use the previous one as reference, provided that there is a usable value...
About the "margin: 2% 0":
Some CSS properties are merged into just one, for example:
margin:
= margin-top:
+ margin-right:
+ margin-bottom:
+ margin-left:
Following example:
.AllMargin {
margin: 50px; // top-right-bottom-left: 50px
}
.MarginVertical {
margin: 50px 0; // top-bottom: 50px, right-left: 0
}
.MarginHorizontal {
margin: 0 50px; // top-bottom: 0, right-left: 50px
}
.TresMargins {
margin: 100px 10px 50px; // top: 100px, right-left: 10px, bottom: 50px
}
.QuatroMargins{
margin: 5px 10px 20px 30px; // top: 5px, right: 10px, bottom: 20px, left: 30px
}
The same happens in properties like: padding
, border
, border-style
, border-color
, always remembering that the order for the 4 parameters of these properties is top right bottom left
(clockwise from the top
)...
Other properties that aggregate various properties within is the box-shadow
, the background
and the filter
, for example, but in these parameters are other.
is relative to the upper attribute. Note the 2nd blue block.
– tinos
Good answer, but I was more positive by the demonstration of this feature to execute code directly in the post ;)
– Bruno Augusto