cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
              <h1>CSS Grid Image Gallery</h1>

<p>So here's the deal: if CSS Grid (namely <code>grid-gap</code>) is supported by your browser, you'll have a wonderful image gallery. If that's not the case, you'll still have a wonderful image gallery by the power of Flexbox.</p>

<p>If your browser does not support flexbox… well, err… yeah… one column layout for you! Still not a broken experience.</p>

<p>Btw.: notice the use of Flexbox inside the Grid! It's not like Grid replaces Flexbox altogether, they wonderfully tag along.</p>

<ul>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
    <li>
        <figure>
            <img src="https://picsum.photos/500/350" alt="Picsum.photos Placeholder Image" />
            <figcaption>
                <strong>Media Name</strong>
            </figcaption>
        </figure>
    </li>
</ul>
            
          
!
            
              body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    
    margin: 0;
    padding: 1.618em 1em;
    
    background: #f4f4f4;
    color: #434343;
    
    @media screen and (min-width: 50em) {
        padding: 1.618em 2em;
    }
    
    @media screen and (min-width: 70em) {
        padding: 2.618em 9.55%;
    }
}

p {
    font-size: 1.125em;
    margin: 0 0 1.5em;
}

ul {
    list-style: none;

    display: flex;
    flex-wrap: wrap;

    margin: 2.618em 0 0;
    padding: 0;
}

li {
    display: flex;
    flex-direction: column;
    
    border: 1px solid #d8d8d8;
    margin: 0 1.25em 1.25em 0;
    max-width: 18.75em;

    background: white;
}

/**
 * in order to trick MS Edge into using Flexbox
 * I'm looking for support of grid-gap and not
 * for display: grid
 */
@supports (grid-gap: 1.25em) {
    ul {
        display: grid;
        grid-gap: 1.25em;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        }
    
    li {
        margin: 0;
        max-width: 100%;
    }
}

// Just some reset styling
figure {
    margin: 0;
}

img {
    max-width: 100%;
}

figcaption {
    display: block;
    
    margin: 0 .618em;
    padding: .618em 0;
}

code {
    padding: .125em;
    background: white;
}
            
          
!
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.
Loading ..................

Console