scroll-padding-bottom
scroll-padding-bottom 属性定义了滚动视口最佳查看区域底部的偏移量:该区域是用于将内容置于用户视图中的目标区域。这允许作者排除滚动视口中被其他内容(例如固定定位的工具栏或侧边栏)遮挡的区域,或者在目标元素和滚动视口边缘之间留出更多喘息空间。
试一试
scroll-padding-bottom: 0;
scroll-padding-bottom: 20px;
scroll-padding-bottom: 2em;
<section class="default-example" id="default-example">
  <div class="scroller" id="example-element">
    <div>1</div>
    <div>2</div>
    <div>3</div>
  </div>
  <div class="info">Scroll »</div>
</section>
.default-example .info {
  inline-size: 100%;
  padding: 0.5em 0;
  font-size: 90%;
  writing-mode: vertical-rl;
}
.scroller {
  text-align: left;
  height: 250px;
  width: 270px;
  overflow-y: scroll;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  border: 1px solid black;
  scroll-snap-type: y mandatory;
}
.scroller > div {
  flex: 0 0 250px;
  background-color: rebeccapurple;
  color: white;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: end;
}
.scroller > div:nth-child(even) {
  background-color: white;
  color: rebeccapurple;
}
语法
css
/* Keyword values */
scroll-padding-bottom: auto;
/* <length> values */
scroll-padding-bottom: 10px;
scroll-padding-bottom: 1em;
scroll-padding-bottom: 10%;
/* Global values */
scroll-padding-bottom: inherit;
scroll-padding-bottom: initial;
scroll-padding-bottom: revert;
scroll-padding-bottom: revert-layer;
scroll-padding-bottom: unset;
值
- <length-percentage>
- 
从滚动视口底部边缘向内的偏移量,可以是有效的长度值或百分比。 
- auto
- 
偏移量由用户代理决定。这通常是 0px,但如果非零值更合适,用户代理可以检测并执行其他操作。 
正式定义
正式语法
scroll-padding-bottom =
auto |
<length-percentage [0,∞]>
<length-percentage> =
<length> |
<percentage>
规范
| 规范 | 
|---|
| CSS 滚动捕捉模块级别 1 # padding-longhands-physical | 
浏览器兼容性
加载中…