Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-padding-bottom — bottom scrolling inset

scroll-padding-bottom insets the bottom edge of a scroll container's optimal viewing region. It helps leave room when scrolling an element into view without changing layout.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

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

scroll-padding-bottom sets an inward offset from the physical bottom edge of a scroll container's scrollport. It affects scrolling elements into view even without snapping; with snapping, it defines the bottom edge of the alignment region. It adds neither ordinary padding nor layout space.

It accepts a nonnegative length, a percentage of the scrollport height, or auto. The initial value auto lets the browser choose, generally zero. The property is not inherited; negative values are invalid. Unlike scroll-padding-block-end, it always addresses the physical bottom. By contrast, scroll-margin-bottom is set on the target element.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>scroll-padding-bottom</title>
<style>
  #scroller {
    height: 200px;
    overflow-y: scroll;
    scroll-padding-bottom: 40px;
    writing-mode: horizontal-tb;
  }
  .space { height: 300px; }
  #target { height: 40px; background: lightblue; }
</style>
<button id="run">Run</button>
<div id="scroller">
  <div class="space"></div>
  <div id="target">Target</div>
  <div class="space"></div>
</div>
<output id="result"></output>
<script>
  const scroller = document.querySelector('#scroller');
  const target = document.querySelector('#target');
  const result = document.querySelector('#result');
  document.querySelector('#run').onclick = () => {
    target.scrollIntoView({ block: 'end', behavior: 'instant' });
    requestAnimationFrame(() => {
      result.textContent = `scrollTop: ${scroller.scrollTop}`;
    });
  };
</script>
</html>

Result

scrollTop: 180

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources