scroll-padding-bottom CSS property
Baseline
Weitgehend verfügbar
Diese Funktion ist gut etabliert und funktioniert auf vielen Geräten und in vielen Browserversionen. Sie ist seit April 2021 browserübergreifend verfügbar.
Die scroll-padding-bottom-Eigenschaft definiert Versätze für die Unterseite der optimalen Anzeigeregion des Scrollportals: die Region, die als Zielregion verwendet wird, um Elemente für den Benutzer im Blickfeld zu platzieren. Dies ermöglicht es dem Autor, Bereiche des Scrollportals auszuschließen, die durch andere Inhalte (wie fest positionierte Werkzeugleisten oder Seitenleisten) verdeckt werden, oder mehr Abstand zwischen einem anvisierten Element und den Rändern des Scrollportals zu schaffen.
Probieren Sie es aus
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;
}
Syntax
/* 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;
Werte
<length-percentage>-
Ein nach innen gerichteter Versatz vom unteren Rand des Scrollportals, als gültige Länge oder Prozentsatz.
auto-
Der Versatz wird vom Benutzeragenten bestimmt. Im Allgemeinen wird dies 0px sein, aber ein Benutzeragent kann etwas anderes tun, wenn ein von Null abweichender Wert angemessener ist.
Formale Definition
| Anfangswert | auto |
|---|---|
| Anwendbar auf | Scrollcontainer |
| Vererbt | Nein |
| Prozentwerte | relative to the scroll container's scrollport |
| Berechneter Wert | wie angegeben |
| Animationstyp | by computed value type |
Formale Syntax
scroll-padding-bottom =
auto |
<length-percentage [0,∞]>
<length-percentage> =
<length> |
<percentage>
Spezifikationen
| Spezifikation |
|---|
| CSS Scroll Snap Module Level 1> # padding-longhands-physical> |
Browser-Kompatibilität
Siehe auch
- CSS scroll snap Modul
- Gut kontrolliertes Scrollen mit CSS scroll snap auf web.dev (2018)