padding-right - CSS(层叠样式表) 编辑
CSS属性 padding-right 是指一个元素在内边距区域(padding area)中右边的宽度。内边距(padding)是指一个元素的内容和边框之间的区域。和外边距(margin)不同,内边距(padding)是不允许有负值的。内边距(padding)可以用四个值声明一个元素的四个方向的内边距(paddings),这是一种CSS缩写属性。
/* <length> values */
padding-right: 0.5em;
padding-right: 0;
padding-right: 2cm;
/* <percentage> value */
padding-right: 10%;
/* Global values */
padding-right: inherit;
padding-right: initial;
padding-right: 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 . |
是否是继承属性 | 否 |
Percentages | refer to the width of the containing block |
适用媒体 | visual |
计算值 | the percentage as specified or the absolute length |
Animation type | a length |
正规顺序 | the unique non-ambiguous order defined by the formal grammar |
Syntax
Values
length
- 当内边距(padding)大小是一个固定单位数值的时候,一定不能为负数。
percentage
- 当内边距(padding)是一个百分比的时候, 百分比是和本身包含的元素的宽度有关的,同样一定不能为负数。
Formal syntax
<length> | <percentage>
Examples
.content { padding-right: 5%; }
.sidebox { padding-right: 10px; }
Specifications
Specification | Status | Comment |
---|---|---|
CSS Basic Box Model padding-right | Working Draft | No change. |
CSS Transitions padding-right | Working Draft | Defines padding-right as animatable. |
CSS Level 2 (Revision 1) padding-right | Recommendation | No change. |
CSS Level 1 padding-right | Recommendation | Initial definition. |
Browser compatibility
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!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
- CSS Box Model
- The
padding
shorthand property can be used to set paddings on all four sides of an element with a single declaration:padding-top
,padding-right
,padding-bottom
, andpadding-left
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论