MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章

CSS属性 padding-top 是指一个元素在内边距区域(padding area)中上方的高度。内边距(padding)是指一个元素的内容和边框之间的区域。和外边距(margin)不同,内边距(padding)是不允许有负值的。内边距(padding)可以用四个值声明一个元素的四个方向的内边距(paddings),这是一种CSS缩写属性。

The effect of the CSS padding-top property on the element box

/* <length> values */
padding-top: 0.5em;
padding-top: 0;
padding-top: 2cm;

/* <percentage> value */
padding-top: 10%;

/* Global values */
padding-top: inherit;
padding-top: initial;
padding-top: unset;

初始值0
适用元素all elements, except table-row-group, table-header-group, table-footer-group, table-row, table-column-group and table-column. It also applies to ::first-letter.
是否是继承属性
Percentagesrefer to the width of the containing block
适用媒体visual
计算值the percentage as specified or the absolute length
Animation typea length
正规顺序the unique non-ambiguous order defined by the formal grammar

Syntax

Values

length
当内边距(padding)大小是一个固定单位数值的时候,一定不能为负数。
percentage
当内边距(padding)是一个百分比的时候, 百分比是和本身包含的元素的宽度有关的,同样一定不能为负数。

Formal syntax

<length> | <percentage>

Examples

.content { padding-top: 5%; }
.sidebox { padding-top: 10px; } 

Specifications

Specification Status Comment
CSS Basic Box Model
padding-top
Working Draft No change from CSS Level 2 (Revision 1)
padding-top
.
CSS Transitions
padding-top
Working Draft Defines padding-top as animatable.
CSS Level 2 (Revision 1)
padding-top
Recommendation No change from CSS Level 1
padding-top
.
CSS Level 1
padding-top
Recommendation Initial definition.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 (Yes) 1.0 (1.0) 4.0 3.5 1.0 (85)
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? ? ?

 See also

文档标签和贡献者

 此页面的贡献者: Huooo
 最后编辑者: Huooo,