Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <h1>CSS Grid + Cicada Principle = <span class="emoji">❤️</span></h1>
<div class="example-wrapper">
  <div class="container">
    <div class="grid__item"><img src="http://placekitten.com/350/450">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/150">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/300">Here is some text. Some items have more.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/250">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/350">Here is some text. Some items have more.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/200">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/350">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/250">Here is some text. Some items have more.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/250">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/300">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/450">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/200">Here is some text.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/300">Here is some text. Some items have more.</div>
    <div class="grid__item"><img src="http://placekitten.com/350/250">Here is some text.</div>
  </div>
</div>
              
            
!

CSS

              
                // Grid styles
.example-wrapper::before {
  content: 'This example requires a browser that supports CSS Grid, like Firefox Nightly. If your browser did support CSS Grid, you would have seen an awesome responsive grid of kittens. But here\'s an image of kitten anyway.';
  display: inline-block;
  margin-bottom: 1em;
  line-height: 1.5;
}

.example-wrapper::after {
  content: url('http://placekitten.com/550/550');
  display: block;
  text-align: center;
}

.example-wrapper > * {
  display: none;
}

.example-wrapper {
  max-width: 40em;
  margin: 0 auto;
}

@supports (display: grid) {
  .example-wrapper::before,
  .example-wrapper::after {
    content: none;
  }
  
  .example-wrapper {
    display: block;
    max-width: none;
  }
 
  .container {
    margin: 2em auto;
    max-width: 54em;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20ch, 1fr));
    grid-gap: 1em 0.5em;
  }

  .grid__item:nth-child(2n+1),
  .grid__item:nth-child(5n) {
    align-self: start;
  }

  .grid__item:nth-child(3n+2),
  .grid__item:nth-child(2n) {
    align-self: center;
  }

  .grid__item:nth-child(5n+3),
  .grid__item:nth-child(3n) {
    align-self: end;
  }
}

// Decorative styles
@import url('https://fonts.googleapis.com/css?family=Eczar:700|Gentium+Basic');
body {
  padding: 1em;
  font-family: 'Gentium Basic', serif;
  color: white;
  background-color: darkslateblue;
  font-size: 1.2em;
  line-height: 1.5;
}

img {
  max-width: 100%;
  border-top-left-radius: 87%;
  border-top-right-radius: 91%;
  border-bottom-left-radius: 100%;
  border-bottom-right-radius: 98%;
}

h1 {
  font-family: 'Eczar', serif;
  text-align: center;
  font-size: 2.5em;
  margin-bottom: 0.25em;
}

.emoji {
  display: inline-block;
  vertical-align: middle;
}

.grid__item:nth-child(2n+1) img {
  border-top-left-radius: 59%;
  border-top-right-radius: 52%;
  border-bottom-left-radius: 59%;
  border-bottom-right-radius: 56%;
  transform: rotate(-6deg);
}

.grid__item:nth-child(3n+2) img {
  border-top-left-radius: 84%;
  border-top-right-radius: 94%;
  border-bottom-left-radius: 72%;
  border-bottom-right-radius: 83%;
  transform: rotate(5deg);
}

.grid__item:nth-child(5n+3) img {
  border-top-left-radius: 73%;
  border-top-right-radius: 100%;
  border-bottom-left-radius: 100%;
  border-bottom-right-radius: 82%;
  transform: rotate(7deg);
}

.grid__item:nth-child(7n+5) img {
  border-top-left-radius: 93%;
  border-top-right-radius: 90%;
  border-bottom-left-radius: 78%;
  border-bottom-right-radius: 85%;
  transform: rotate(-2deg);
}

.grid__item:nth-child(11n+7) img {
  border-top-left-radius: 68%;
  border-top-right-radius: 68%;
  border-bottom-left-radius: 53%;
  border-bottom-right-radius: 83%;
  transform: rotate(-2deg);
}
              
            
!

JS

              
                /* Squishy shaped image effect credit to Charlotte Jackson in her article, Magic randomisation with nth-child and Ciacda Princple available at https://www.lottejackson.com/learning/nth-child-cicada-principle */
              
            
!
999px

Console