padding 属性允许您指定元素内容与其边框之间应显示的空间数量减去;
此属性的值应该可以是长度,百分比,也可以是继承.如果值为 inherit ,则它将具有与其父元素相同的填充.如果使用百分比,则百分比是包含框.
以下CSS属性可用于控制列表.您还可以使用以下属性和减号为框的每一侧的填充设置不同的值;
padding-bottom 指定元素的底部填充.
padding-top 指定顶部填充元素.
padding-left 指定元素的左边距.
padding-right 指定元素的正确填充.
填充用作前面属性的简写.
现在,我们将看到如何将这些属性与示例一起使用.
填充底部属性
padding-bottom 属性设置元素的底部填充(空格).这可以采用%的长度值.
这是一个示例 :
This is a paragraph with a specified bottom padding
This is another paragraph with a specified bottom padding in percent
The padding-top Property
padding-top属性设置元素的顶部填充(空格)。 这可以采用%的长度值。
这是一个例子:
This is a paragraph with a specified top padding
This is another paragraph with a specified top padding in percent
The padding-left Property
padding-left属性设置元素的左边距(空格)。 这可以采用%的长度值。
这是一个例子:
This is a paragraph with a specified left padding
This is another paragraph with a specified left padding in percent
The padding-right Property
padding-right属性设置元素的右边距(空格)。 这可以采用%的长度值。
这是一个例子:
This is a paragraph with a specified right padding
This is another paragraph with a specified right padding in percent
The Padding Property
padding属性设置元素的左,右,上和下填充(空格)。 这可以采用%的长度值。
这是一个例子:
all four padding will be 15px
top and bottom padding will be 10px, left and right padding will be 2% of the total width of the document.
top padding will be 10px, left and right padding will be 2% of the total width of the document, bottom padding will be 10px
top padding will be 10px, right padding will be 2% of the total width of the document, bottom padding and top padding will be 10px