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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <h4>Image Gallery with Variants of Overlay Text</h4>
<p>A small image gallery with six pictures &ndash; styled with CSS Flexbox and 'position:absolute'. The text above the pictures can be seen at six (of nine possible) different positions. As standard I've set "top center" and derived the variants from there.</p>
<div class="box-grid">
  <div class="box-flex">
    <img class="box-img" src="https://picsum.photos/230/300?random=1" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h5 class="box-caption">Top Center</h5>
  </div><!-- end: box-flex -->
  <div class="box-flex box-flex-center">
    <img class="box-img" src="https://picsum.photos/230/300?random=2" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h5 class="box-caption">Center Center - no overflow thanks to max-width and word-break</h5>
  </div><!-- end: box-flex -->
  <div class="box-flex box-flex-bottom">
    <img class="box-img" src="https://picsum.photos/230/300?random=3" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h5 class="box-caption">Bottom Center</h5>
  </div><!-- end: box-flex -->
  <div class="box-flex box-flex-top-right">
    <img class="box-img" src="https://picsum.photos/230/300?random=4" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h5 class="box-caption">Top Right</h5>
  </div><!-- end: box-flex -->
  <div class="box-flex box-flex-center-left">
    <img class="box-img" src="https://picsum.photos/230/300?random=5" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h5 class="box-caption">Center Left</h5>
  </div><!-- end: box-flex -->
  <div class="box-flex box-flex-bottom-right">
    <img class="box-img" src="https://picsum.photos/230/300?random=6" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h5 class="box-caption">Bottom Right</h5>
  </div><!-- end: box-flex -->
</div><!-- end: box.grid -->
<br>
<hr>
<br>
<h4>Multiple Caption Overlays</h4>
<div class="box-grid">
  <div class="box-flex">
    <img class="box-img" src="https://picsum.photos/230/300?random=1" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h5 class="box-caption">Top Center</h5>
    <h6 class="box-caption align-end">align-self: flex-end</h6>
  </div><!-- end: box-flex -->
  <div class="box-flex box-flex-center">
    <img class="box-img" src="https://picsum.photos/230/300?random=2" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h6 class="box-caption align-start">align-self: flex-start</h6>
    <h5 class="box-caption">Center Center</h5>
    <h6 class="box-caption align-end">align-self: flex-end</h6>
  <!-- end: box-flex --></div>
  <div class="box-flex box-flex-bottom">
    <img class="box-img" src="https://picsum.photos/230/300?random=3" alt="Image form https://picsum.photos" title="Image form https://picsum.photos">
    <h6 class="box-caption align-center">align-self: center</h6>
    <h5 class="box-caption">Bottom Center</h5>
  </div><!-- end: box-flex -->
</div><!-- end box-grid -->
</body>
              
            
!

CSS

              
                * { box-sizing: border-box;}

html {
  font-size: 100%;
}
body {
  padding: 1rem;
  font-familiy: Verdana, Geneva, sans-serif;
}
/* The Container */
.box-grid {
  display: -ms-grid;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  grid-gap: 1.5rem;
  justify-items: center;
  padding: 0;
}

/* Styles for the caption overlays */
/* Standard Box: Top Center */
.box-flex {
  display: flex;
  flex-flow: row nowrap;
  align-items: flex-start;
  justify-content: center;
  padding: .5rem;
  text-align: center;
  font-size: 1.2rem;
  background-color: #333333;
  color: #d9d9d9;
}

/* Box: Center Center */
.box-flex-center {
  align-items: center;
}

/* Box: Bottom Center */
.box-flex-bottom {
  align-items: flex-end;
}

/* Box: Top Right */
.box-flex-top-right {
  justify-content: flex-end;
}

/* Box: Center Left */
.box-flex-center-left {
  align-items: center;
  justify-content: flex-start;
}

/* Box: Bottom Right */
.box-flex-bottom-right {
  align-items: flex-end;
  justify-content: flex-end;
}

.box-img {
  transition: -webkit-transform .5s ease-in-out;
  transition: transform .5s ease-in-out;
}

.box-img:hover {
  -webkit-transform: scale(1.07);
  transform: scale(1.07);
}

.box-caption {
  position: absolute;
  max-width: 200px;
  margin: 0;
  padding: .5rem;
  word-break: break-word;
  font-size: 1.25rem;
  background-color: rgba(0,0,0,.3);
  color: #f2f2f2;
}

.box-caption:hover {
  background-color: rgba(0,0,0,.5);
  color: #e6e6e6;
  transition: all ease .5s;
}

/* Styles for multiple caption overlays */

/* align-self: flex-start */
.align-start {
  align-self: flex-start;
}

/* align-self: center */
.align-center {
  -ms-grid-row-align: center;
  align-self: center;
}

/* align-self: flex-end */
.align-end {
  align-self: flex-end;
}
              
            
!

JS

              
                
              
            
!
999px

Console