If text-indent is set to a percentage value, which width is it using for the calculation?
Another problem related to the rewrite of my Textarea Line Count plugin (<-- shameless plug)
开发者_JS百科The text-indent
property of CSS provides white space preceding the first line of text. Possible values include measurements in px
, em
, pt
, etc. but also as a percentage %
.
So, let's say you specify that your text-area should have: text-indent: 30%
. But, 30%
of which width is used to perform this calculation? Is it the outer width or the inner width? In other words, are any of the following included in the width
:
- Border
- Margin
- Padding
30% the width of the parent. It will always inherit the parent width for percentage.
Padding and border add to the parents width, whereas margin does not, ie
#example {width: 200px; padding: 0 5px; border: 1px solid #000;}
would be a total width of 212px.
Margin is a positiong tool and only affects what space should be between objects.
I've figured it out. Border is not included in the calculation, since this technically isn't included in the element's width. Only inner width is measured; no border, padding, margin, etc.
精彩评论