CSS scroll-padding-bottom 属性指定元素滚动对齐区域的底部偏移量。
属性值
<length>: 长度值是数值,例如 px、em、百分比。
适用范围
所有 HTML 元素。
DOM 语法
object.style.scrollPaddingBottom = "length";
CSS scroll-padding-bottom - 零值
以下示例演示如何使用scroll-padding-bottom属性来确保容器底部没有填充 -
<html>
<head>
<style>
.scroll-container {
width: 350px;
height: 200px;
overflow-x: hidden;
overflow-y: scroll;
scroll-snap-type: y mandatory;
scroll-padding-bottom: 0;
}
.scrolling-section1,
.scrolling-section2,
.scrolling-section3 {
width: 350px;
height: 200px;
scroll-snap-align: end;
}
.scrolling-section1 {
background-color: rgb(220, 235, 153);
}
.scrolling-section2 {
background-color: rgb(230, 173, 218);
}
.scrolling-section3 {
background-color: rgb(119, 224, 210);
}
</style>
</head>
<body>
<h3>使用滚动条箭头滚动内容以查看效果。</h3>
<div class="scroll-container">
<div class="scrolling-section1">scroll-padding-bottom: 0</div>
<div class="scrolling-section2">scroll-padding-bottom: 0</div>
<div class="scrolling-section3">scroll-padding-bottom: 0</div>
</div>
</body>
</html>
CSS scroll-padding-bottom- 长度值
以下示例演示如何使用scroll-padding-bottom属性在可滚动容器的底部添加填充 -
<html>
<head>
<style>
.scroll-container {
width: 350px;
height: 200px;
overflow-x: hidden;
overflow-y: scroll;
scroll-snap-type: y mandatory;
scroll-padding-bottom: 25px;
}
.scrolling-section1,
.scrolling-section2,
.scrolling-section3 {
width: 350px;
height: 200px;
scroll-snap-align: end;
}
.scrolling-section1 {
background-color: rgb(220, 235, 153);
}
.scrolling-section2 {
background-color: rgb(230, 173, 218);
}
.scrolling-section3 {
background-color: rgb(119, 224, 210);
}
</style>
</head>
<body>
<h3>使用滚动条箭头滚动内容以查看效果。</h3>
<div class="scroll-container">
<div class="scrolling-section1">scroll-padding-bottom: 25px</div>
<div class="scrolling-section2">scroll-padding-bottom: 25px</div>
<div class="scrolling-section3">scroll-padding-bottom: 25px</div>
</div>
</body>
</html>