← All elements

Scroll Shadow Panel

by @admin · 4 views

<div class="pc-shadow" tabindex="0" role="region" aria-label="Size guide, scrollable">
  <h3>Chest size guide</h3>
  <ul>
    <li><span>XS</span><span>86 cm</span></li>
    <li><span>S</span><span>91 cm</span></li>
    <li><span>M</span><span>97 cm</span></li>
    <li><span>L</span><span>102 cm</span></li>
    <li><span>XL</span><span>107 cm</span></li>
    <li><span>2XL</span><span>112 cm</span></li>
    <li><span>3XL</span><span>117 cm</span></li>
    <li><span>4XL</span><span>122 cm</span></li>
  </ul>
</div>

About this layout

A scrolling panel whose top and bottom shadows appear only while more content is hidden, using layered backgrounds with background-attachment: local.

How it works

The panel has four background layers. Two white gradients use background-attachment: local, so they move with the content and cover the shadows once you reach an end. Two radial shadows use scroll, so they stay fixed at the top and bottom edges. The result is that a shadow shows only while more content is hidden.

Ways to customise it

  • Change the 180px height or the 280px width of the panel.
  • Raise the 0.28 shadow opacity for stronger edges.
  • Change the 40px cover size and 14px shadow size.

Good to know

The panel has tabindex=0 and a label, so keyboard users can focus it and scroll with the arrow keys. The cover colour must match the panel background, or a white band will show.

Open an example, copy the HTML and the CSS, and paste them into your page. There is nothing to install and no JavaScript to load.

More in Layout

View all →