padding-bottom

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

padding-bottom CSS 属性用于设置元素底部内边距区域的高度。

试一试

padding-bottom: 1em;
padding-bottom: 10%;
padding-bottom: 20px;
padding-bottom: 1ch;
padding-bottom: 0;
<section id="default-example">
  <div class="transition-all" id="example-element">
    <div class="box">
      Far out in the uncharted backwaters of the unfashionable end of the
      western spiral arm of the Galaxy lies a small unregarded yellow sun.
    </div>
  </div>
</section>
#example-element {
  border: 10px solid #ffc129;
  overflow: hidden;
  text-align: left;
}

.box {
  border: dashed 1px;
}

元素的内边距区域是其内容与其边框之间的空间。

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

注意: padding 属性可以通过单个声明设置元素所有四个方向的内边距。

语法

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

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

/* Global values */
padding-bottom: inherit;
padding-bottom: initial;
padding-bottom: revert;
padding-bottom: revert-layer;
padding-bottom: unset;

padding-bottom 属性指定为一个值,该值从以下列表中选择。与外边距不同,内边距不允许使用负值。

<length>

内边距的固定值大小。必须是非负数。

<percentage>

内边距的百分比大小,相对于包含块的行内尺寸(在水平语言中为宽度,由writing-mode定义)。必须是非负数。

正式定义

初始值0
应用于所有元素,除了 table-row-grouptable-header-grouptable-footer-grouptable-rowtable-column-grouptable-column。它也适用于 ::first-letter::first-line
继承性
百分比参照包含块的宽度
计算值指定的百分比或绝对长度
动画类型一个长度

正式语法

padding-bottom = 
<length-percentage [0,∞]>

<length-percentage> =
<length> |
<percentage>

示例

使用像素和百分比设置底部内边距

css
.content {
  padding-bottom: 5%;
}
.side-box {
  padding-bottom: 10px;
}

规范

规范
CSS Box Model Module Level 3
# 物理内边距

浏览器兼容性

另见