在检查一些代码时,我发现了这个新声明:-webkit-padding-start
但我无法理解与现有padding-left
属性有什么区别。我已经阅读了Mozilla Developers上的页面并创建了一个fiddle,但我仍然不确定。
3 回答
Apart from -webkit-padding-start
being nonstandard, the difference is that when writing direction is right to left, -webkit-padding-start
puts padding to the right (effectively, gets converted to padding-right
).
If the property were standardized, it would be useful for style sheets that are meant to be used for documents containing texts in different writing systems. You could then put padding at the start of text, provided that you have set the dir
attribute in HTML or the direction
property in CSS properly to correspond the directionality. So the padding would be on the left of the start of text e.g. in Western languages but to the right of the start of the text (which runs from right to left) e.g. in Arabic, Persian, or Hebrew texts.
如果计算的方向是从左到右,ltr
则-moz-padding-start
设置 ,left-padding:;
否则设置right-padding:;
。
例如:
HTML:
<p><a class="left">padding-start: 20px (ltr)</a>
</p>
<p><a class="right">padding-start: 20px (rtl)</a>
</p>
CSS:
.left {
direction: ltr;
border: 1px solid #000;
-moz-padding-start : 20px;
-webkit-padding-start : 20px;
}
.right {
direction: rtl;
border: 1px solid #000;
-moz-padding-start : 20px;
-webkit-padding-start : 20px;
}
如果书写方向是从左到右,
-webkit-padding-start overrides padding-left
. 如果书写方向是从右到左,-webkit-padding-start overrides padding-right
.
来源:CSS-信息