Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-margin-bottom — bottom offset for scrolling

scroll-margin-bottom adjusts an element’s bottom area boundary for scrolling into view and scroll snapping, 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-margin-bottom: <length>;

scroll-margin-bottom specifies an outset from the physical bottom edge of the bounding rectangle of the element’s transformed border box. Applying this outset defines the bottom edge of the element’s scroll snap area. Unlike margin-bottom, it adds no layout space. It also affects scrolling into view without snapping enabled.

It accepts <length>, including negative values, but not percentages or auto. Initially 0, it is not inherited. Positive values extend the area downward.

Set it on the target; set scroll-padding-bottom on the container. bottom stays physical; scroll-margin-block-end follows the writing mode.

The example requests end alignment with scrollIntoView(). The expected gap is 32px, provided the scroll range permits it.

Examples

<!doctype html>
<meta charset="utf-8">
<title>scroll-margin-bottom</title>
<style>
  #scroller { height: 200px; overflow: auto; }
  .space { height: 240px; }
  #target { height: 60px; scroll-margin-bottom: 32px; 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>
<pre id="result"></pre>
<script>
  const scroller = document.getElementById('scroller');
  const target = document.getElementById('target');
  document.getElementById('run').onclick = () => {
    target.scrollIntoView({ block: 'end', behavior: 'instant' });
    const gap = Math.round(
      scroller.getBoundingClientRect().bottom -
      target.getBoundingClientRect().bottom
    );
    document.getElementById('result').textContent =
      `scrollTop=${scroller.scrollTop}; gap=${gap}px`;
  };
</script>

Result

scrollTop=132; gap=32px

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