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

              
                <ul class="grid">
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/300/200/?random" alt="">
      <figcaption>Vehicula Quam Nibh</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/200/800/?random" alt="">
      <figcaption>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ullamcorper nulla non metus auctor fringilla.</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/200/300/?random" alt="">
      <figcaption>Parturient Mollis Malesuada Tristique Inceptos.</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/400/200/?random" alt="">
      <figcaption>Vehicula Quam Nibh</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/200/600/?random" alt="">
      <figcaption>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ullamcorper nulla non metus auctor fringilla.</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/600/600/?random" alt="">
      <figcaption>Parturient Mollis Malesuada Tristique Inceptos.</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/420/300/?random" alt="">
      <figcaption>Vehicula Quam Nibh</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/800/800/?random" alt="">
      <figcaption>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ullamcorper nulla non metus auctor fringilla.</figcaption>
    </figure>
  </li>
  <li>
    <figure class="grid__figure">
      <img src="https://picsum.photos/640/400/?random" alt="">
      <figcaption>Parturient Mollis Malesuada Tristique Inceptos.</figcaption>
    </figure>
  </li>
</ul>
              
            
!

CSS

              
                // --------------------------
// Set-up styles
// --------------------------
* { box-sizing: border-box; }
body { background: slategray; margin: 0; padding: 3em 1em;}
ul { list-style: none; margin: 0; padding: 0;}
figure { margin: 0; }
figcaption { font-style: italic; font-size: 0.8em; color: grey; line-height: 1.4; }

// --------------------------
// Grid styles
// --------------------------
.grid {
  display: grid;
  grid-auto-flow: column; // display the items in columns only, ie horizontal
  grid-auto-columns: 90%; // create as many columns as there are items. 90% so we can see next item on the right.
  grid-gap: 1em;
  overflow-x: scroll; // scroll only within the grid, not entire page
  -webkit-overflow-scrolling: touch; // better scrolling on touch
  padding: 2em 1em;
  background: white;
  
  @media all and (min-width: 600px) {
    grid-auto-flow: initial; // default: display items in rows and cols
    grid-template-columns: repeat(auto-fit, minmax(auto,20em)); // as many columns with max-width of 20em;
    justify-content: center; // center the items - this is optional
  }
  
  &__figure {
    display: grid;
    grid-template-rows: 15em 1fr; // 15em high row for image – value could be whatever
    grid-gap: 1em;
    
    img {
      width: 100%;
      height: 100%;
      object-fit: cover; // crop image within its cell
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console