开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜