Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. CSS:层叠样式表
  3. CSS 参考
  4. 属性
  5. scroll-padding-bottom

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

scroll-padding-bottom

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2021年4月.

scroll-padding-bottom 属性定义了滚动口的最优视区——用于在用户视野中放置内容的目标区域——的下内边距。作者由此得以排除滚动口被其他内容(如固定定位的工具栏或侧边栏)所遮挡的区域,或在目标元素与滚动口的边之间留出更多余地。

尝试一下

scroll-padding-bottom: 0;
scroll-padding-bottom: 20px;
scroll-padding-bottom: 2em;
<section>  <div>    <div>1</div>    <div>2</div>    <div>3</div>  </div>  <div>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: #fff;  font-size: 30px;  display: flex;  align-items: center;  justify-content: center;  scroll-snap-align: end;}.scroller > div:nth-child(even) {  background-color: #fff;  color: rebeccapurple;}

语法

css
/* 关键字值 */scroll-padding-bottom: auto;/* <length> 值 */scroll-padding-bottom: 10px;scroll-padding-bottom: 1em;scroll-padding-bottom: 10%;/* 全局值 */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,但用户代理可检测非零值是否更合理并另行处理。

形式定义

初始值auto
适用元素scroll containers
是否是继承属性
Percentagesrelative to the scroll container's scrollport
计算值as specified
动画类型按计算值的类型

形式语法

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

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

规范

Specification
CSS Scroll Snap Module Level 1
# padding-longhands-physical

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp