📅  最后修改于: 2020-11-04 06:52:58             🧑  作者: Mango
CSS Padding属性用于定义元素内容和元素边框之间的空间。
它与CSS边距的不同之处在于CSS边距定义元素周围的空间。CSS填充受背景颜色的影响。清除内容周围的区域。
可以使用单独的属性分别更改顶部,底部,左侧和右侧的填充。您还可以通过使用速记填充属性来一次更改所有属性。
Property | Description |
---|---|
padding | It is used to set all the padding properties in one declaration. |
padding-left | It is used to set left padding of an element. |
padding-right | It is used to set right padding of an element. |
padding-top | It is used to set top padding of an element. |
padding-bottom | It is used to set bottom padding of an element. |
Value | Description |
---|---|
length | It is used to define fixed padding in pt, px, em etc. |
% | It defines padding in % of containing element. |
This is a paragraph with no specified padding.
This is a paragraph with specified paddings.
输出:
This is a paragraph with no specified padding.
This is a paragraph with specified paddings.