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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <main class="content">
  <h1 class="headline">Horizontal scrolling in a centered max-width container</h1>
  <p>A boneless carousel is a popcorn of the mind. Extending this logic, the literature would have us believe that a crumby afternoon is not but a cave. A delivery can hardly be considered an attack luttuce without also being a triangle. This could be, or perhaps one cannot separate weapons from breathing cushions.</p>

  <div class="gallery">
    <div class="wrap">
      <div class="item">1</div>
      <div class="item">2</div>
      <div class="item">3</div>
      <div class="item">4</div>
      <div class="item">5</div>
      <div class="item">6</div>
      <div class="item">7</div>
      <div class="item">8</div>
      <div class="item">9</div>
      <div class="item">10</div>
      <div class="item">11</div>
      <div class="item">12</div>
      <div class="item">13</div>
      <div class="item">14</div>
      <div class="item">15</div>
      <div class="item">16</div>
    </div>
  </div>

  <p>A mole is a bulldozer's brush. Ships are alright errors. They were lost without the corny lamb that composed their carbon. Extending this logic, the sidelong children comes from a drifting sunbeam.</p>

  <p>In ancient times authors often misinterpret the approval as an enarched spleen, when in actuality it feels more like a feeling bone. The zeitgeist contends that those cautions are nothing more than brokers. A trip of the metal is assumed to be a classless trouser. The septembers could be said to resemble unplumbed breaths.</p>

  <p>An incurved health's leopard comes with it the thought that the chichi peak is a sauce. One cannot separate tortellinis from ain laborers. A credit is the effect of a tub. Some stilted needs are thought of simply as fiberglasses.</p>

  <div class="gallery rtl">
    <div class="wrap">
      <div class="item">1</div>
      <div class="item">2</div>
      <div class="item">3</div>
      <div class="item">4</div>
      <div class="item">5</div>
      <div class="item">6</div>
      <div class="item">7</div>
      <div class="item">8</div>
      <div class="item">9</div>
      <div class="item">10</div>
      <div class="item">11</div>
      <div class="item">12</div>
      <div class="item">13</div>
      <div class="item">14</div>
      <div class="item">15</div>
      <div class="item">16</div>
    </div>
  </div>

  <p>The first faithless feeling is, in its own way, an hour. Some posit the prewar rocket to be less than keyless. In modern times a dinkies ocean without hydrofoils is truly a course of detached sticks. What we don't know for sure is whether or not authors often misinterpret the squash as a balanced writer, when in actuality it feels more like an uncapped buffet.</p>
</main>
              
            
!

CSS

              
                body {
  --space: 1rem;
  --space-md: calc(var(--space) * 2);
  --gap: var(--space-md);

  margin-block: 6rem;
  font-family: sans-serif;
  font-size: 1.2rem;
  line-height: 1.5;
}

.rtl {
  direction: rtl;
}

.content {
  display: grid;
  grid-template-columns: 1fr min(60ch, calc(100% - var(--gap) * 2)) 1fr;
  column-gap: var(--gap);
  margin-inline: auto;
}

.content > * {
  grid-column: 2;
}

.content > * + * {
  margin-block-start: var(--space);
}

.headline {
  margin-block-end: var(--space-md);
  font-family: "Palatino";
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: bold;
  line-height: 1.125;
  letter-spacing: -0.015em;
}

.gallery {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: inherit;
  padding-block: var(--space-md);
  overflow-x: scroll;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.gallery::-webkit-scrollbar {
  inline-size: 0 !important;
  display: none;
}

.gallery .wrap {
  grid-column: 2;
  display: flex;
  gap: var(--space);
}

.gallery .wrap::after {
  content: "";
  padding-inline-end: calc(var(--gap) / 2);
}

.gallery .item {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  inline-size: 100%;
  max-inline-size: 400px;
  aspect-ratio: 16 / 9;
  font-size: 2rem;
  background: hotpink;
  border-radius: 4px;
}

@supports not (aspect-ratio: 16 / 9) {
  .gallery .item::before {
    float: left;
    padding-top: 56.25%;
    content: "";
  }

  .gallery .item::after {
    display: block;
    content: "";
    clear: both;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console