Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <h1>Pure CSS scrolling shadows with <code>background-attachment: local;</code></h1>

<p><em><a href="http://lea.verou.me/2012/04/background-attachment-local/">Lea's approach</a>, but also applied to a horizontal scroll container</em></p>

<h2>Vertical Scroll Container</h2>

<div class="scrollcontainer scrollcontainer--vertical">
  <div class="scrollcontainer__content">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin consectetur sit amet ipsum eget aliquet. Suspendisse vitae lacinia ligula. Donec fringilla, nisl non pharetra ornare, metus nibh sagittis eros, vel porta mauris leo sodales quam. Nulla nec diam cursus, suscipit mauris quis, scelerisque felis. Duis sollicitudin nulla at libero porttitor, ut efficitur elit consequat. Morbi fringilla gravida ullamcorper. Cras vehicula sapien ac tellus scelerisque vehicula. Phasellus rhoncus sem eu ultricies aliquet. Suspendisse non justo at eros lacinia congue. Donec laoreet ultrices ultrices. Nulla velit velit, aliquet quis blandit sodales, suscipit scelerisque tortor. Donec non aliquet ipsum, sit amet tempus lorem. Pellentesque euismod suscipit ultricies.</p>
    <p>Nunc in blandit metus, sit amet iaculis nulla. Pellentesque lacinia diam sed enim gravida vehicula. Praesent ac nisi sit amet nisl sodales elementum. Etiam vitae nunc at nibh condimentum finibus non convallis mauris. Fusce pretium dui eu est fringilla, ut ultricies nunc euismod. Aliquam elementum cursus urna nec vehicula. Sed ac ligula velit. Morbi leo nulla, efficitur ut leo eget, porttitor egestas ex. Pellentesque viverra ligula interdum, fringilla magna eu, ultrices mi. Proin nulla quam, malesuada fringilla vulputate sit amet, condimentum et mauris. Etiam ante dolor, ultrices at lobortis in, iaculis sit amet eros.</p>
  </div>
</div>

<h2>Horizontal Scroll Container</h2>

<div class="scrollcontainer scrollcontainer--horizontal">
    <div class="scrollcontainer__content">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin consectetur sit amet ipsum eget aliquet. Suspendisse vitae lacinia ligula. Donec fringilla, nisl non pharetra ornare, metus nibh sagittis eros, vel porta mauris leo sodales quam. Nulla nec diam cursus, suscipit mauris quis, scelerisque felis. Duis sollicitudin nulla at libero porttitor, ut efficitur elit consequat. Morbi fringilla gravida ullamcorper. Cras vehicula sapien ac tellus scelerisque vehicula. Phasellus rhoncus sem eu ultricies aliquet. Suspendisse non justo at eros lacinia congue. Donec laoreet ultrices ultrices. Nulla velit velit, aliquet quis blandit sodales, suscipit scelerisque tortor. Donec non aliquet ipsum, sit amet tempus lorem. Pellentesque euismod suscipit ultricies.</p>
    <p>Nunc in blandit metus, sit amet iaculis nulla. Pellentesque lacinia diam sed enim gravida vehicula. Praesent ac nisi sit amet nisl sodales elementum. Etiam vitae nunc at nibh condimentum finibus non convallis mauris. Fusce pretium dui eu est fringilla, ut ultricies nunc euismod. Aliquam elementum cursus urna nec vehicula. Sed ac ligula velit. Morbi leo nulla, efficitur ut leo eget, porttitor egestas ex. Pellentesque viverra ligula interdum, fringilla magna eu, ultrices mi. Proin nulla quam, malesuada fringilla vulputate sit amet, condimentum et mauris. Etiam ante dolor, ultrices at lobortis in, iaculis sit amet eros.</p></div>
</div>
            
          
!

CSS

            
              body {
  background: white;
  font-family: sans-serif;
  text-align: center;
  padding: 1em;
}

.scrollcontainer {
  margin: 0 auto;
  height: 10em;
  width: 40em;
  border: 1px solid #ccc;
}

.scrollcontainer__content {
  padding: 0 1em;
  text-align: left;
}

.scrollcontainer--vertical {
  overflow-x: scroll;
  --background-color: rgba(255, 255, 255, 1);
  --transparent: rgba(255, 255, 255, 0); /* We can't use "transparent" directly, because Safari would interpret the color as "transparent black" (see https://css-tricks.com/thing-know-gradients-transparent-black/). Using this workaround, it works fine. */
  --shadow-color: rgba(34,34,34, 0.5);
  --shadow-size: 0.75em;

  background: 
    linear-gradient(var(--background-color), var(--background-color), var(--transparent) calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 50% 0, var(--shadow-color), var(--transparent)),
    linear-gradient(to top, var(--background-color), var(--background-color), var(--transparent) calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 50% 100%, var(--shadow-color), var(--transparent)) 0 100%;
  background-color: var(--background-color);
  background-repeat: no-repeat;
  background-attachment: local, scroll,local,  scroll;
  background-size: 100% 100%, 100% var(--shadow-size), 100% 100%, 100% var(--shadow-size);
}

.scrollcontainer--horizontal {
  overflow-y: scroll;
  --background-color: rgba(255, 255, 255, 1);
  --transparent: rgba(255, 255, 255, 0); /* We can't use "transparent" directly, because Safari would interpret the color as "transparent black" (see https://css-tricks.com/thing-know-gradients-transparent-black/). Using this workaround, it works fine. */
  --shadow-color: rgba(34,34,34, 0.5);
  --shadow-size: 0.75em;

  background:
    linear-gradient(to right, var(--background-color), var(--background-color), var(--transparent) calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 0 50%, var(--shadow-color), var(--transparent)),
    linear-gradient(to left, var(--background-color), var(--background-color), var(--transparent) calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 100% 50%, var(--shadow-color), var(--transparent)) 100%;
  background-color: var(--background-color);
  background-repeat: no-repeat;
  background-attachment: local, scroll, local, scroll;
  background-size: 100% 100%, var(--shadow-size) 100%, 100% 100%, var(--shadow-size) 100%;
  height: 100%;
}

.scrollcontainer--horizontal .scrollcontainer__content {
  white-space: nowrap;
}
            
          
!

JS

            
              
            
          
!
999px

Console