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

              
                    <p class="label">Just one image:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"></p>

    <p class="label">Two images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"></p>

    <p class="label">Three images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"></p>

    <p class="label">Four images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"></p>

    <p class="label">Five images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"></p>

    <p class="label">Six images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"></p>

    <p class="label">Seven images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"></p>

    <p class="label">Eight images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"></p>

    <p class="label">Nine images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"></p>

    <p class="label">Ten images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"></p>

    <p class="label">101 images:</p>
    <p><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-2.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-3.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-4.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-5.jpg"><img src="https://silem.link/_assets/images/flexible-image-galleries-1.jpg"></p>

              
            
!

CSS

              
                p {
  width: 500px;
  margin: 0 auto;
}

p > img {
  padding-bottom: 5px;
}


/*** 1 ***/

img:only-child {
  max-width: 100%;
}

/*** 2 ***/
img:first-child:nth-last-child(2) ~ img, img:first-child:nth-last-child(2) {
  max-width: 49.5%;
  margin-right: 1%;
}
img:first-child:nth-last-child(2) ~ img:nth-child(2) {
  margin-right: 0;
}

/*** 3 ***/
img:first-child:nth-last-child(3) ~ img, img:first-child:nth-last-child(3) {
  max-width: 32.6%;
  margin-right: 1%;
}
img:first-child:nth-last-child(3) ~ img:nth-child(3) {
  margin-right: 0;
}

/*** 4 ***/
img:first-child:nth-last-child(4) ~ img, img:first-child:nth-last-child(4) {
  max-width: 49.5%;
  margin-right: 1%;
}
img:first-child:nth-last-child(4) ~ img:nth-child(2n+2) {
  margin-right: 0;
}


/*** 5, 8, 11, ... ***/

/* First two are half-sized (99% / 2) */
img:first-child:nth-last-child(3n+5) ~ img, img:first-child:nth-last-child(3n+5) {
  max-width: 49.5%;
  margin-right: 1%;
}

/* Last n - 2 are (98% / 3) */
img:first-child:nth-last-child(3n+5) + img ~ img {
  max-width: 32.6%;
  margin-right: 1%;
}

/* But second, fifth, eighth, ... have no right margin */
img:first-child:nth-last-child(3n+5) ~ img:nth-child(3n+2) {
  margin-right: 0;
}


/*** 6, 9, 12, ... ***/

/* Six, nine, twelve, ... are all (98% / 3) */
img:first-child:nth-last-child(3n+6) ~ img, img:first-child:nth-last-child(3n+6) {
  max-width: 32.6%;
  margin-right: 1%;
}

/* Every third one of these has no right margin. */
img:first-child:nth-last-child(3n+6) ~ img:nth-child(3n) {
  margin-right: 0;
}


/*** 7, 10, 13, ... ***/

/* First four are half-sized (99% / 2) */
img:first-child:nth-last-child(3n+7) ~ img, img:first-child:nth-last-child(3n+7) {
  max-width: 49.5%;
  margin-right: 1%;
}

/* Last n - 4 are (98% / 3) */
img:first-child:nth-last-child(3n+7) + img + img + img ~ img {
  max-width: 32.6%;
  margin-right: 1%;
}

/* The second and fourth, seventh, tenth, ... have no right margin */
img:first-child:nth-last-child(3n+7) + img, img:first-child:nth-last-child(3n+7) ~ img:nth-child(3n+4) {
  margin-right: 0;
}

              
            
!

JS

              
                
              
            
!
999px

Console