Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <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>
            
          
!
            
              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);
  --shadow-color: rgba(34,34,34, 0.5);
  --shadow-size: 20px;

  background: 
    linear-gradient(var(--background-color), var(--background-color), transparent calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 50% 0, var(--shadow-color), transparent),
    linear-gradient(to top, var(--background-color), var(--background-color), transparent calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 50% 100%, var(--shadow-color), 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);
  --shadow-color: rgba(34,34,34, 0.5);
  --shadow-size: 20px;

  background:
    linear-gradient(to right, var(--background-color), var(--background-color), transparent calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 0 50%, var(--shadow-color), transparent),
    linear-gradient(to left, var(--background-color), var(--background-color), transparent calc(var(--shadow-size) * 2)),
    radial-gradient(farthest-side at 100% 50%, var(--shadow-color), 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;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console