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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.</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;
}

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;
        
        @media screen and (min-width: 30em) {
            grid-template-columns: repeat(2, 1fr);
        }

        @media screen and (min-width: 50em) {
            grid-template-columns: repeat(3, 1fr);
        }

        @media screen and (min-width: 70em) {
            grid-template-columns: repeat(4, 1fr);
        }

        @media screen and (min-width: 100em) {
            grid-template-columns: repeat(5, 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
Loading ..................

Console