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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <h2>Example 1</h2>
<button onClick="flip()">Flip It</button>
  <div class="flipper">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
    <div class="item">4</div>
    <div class="item">5</div>
    <div class="item">6</div>
    <div class="item">7</div>
    <div class="item">8</div>
    <div class="item">9</div>
    <div class="item">10</div>
  </div>

<h2>Example 2</h2>
<div class="tracks">
    <div class="track">
      <h2>The Future (Ft. The R.O.C.)</h2>
      <button>⭐</button>
      <button>❤️</button>
      <button>❌</button>
    </div>
    <div class="track">
      <h2>Bounce With Me (Ft. Jermaine Dupri & Xscape)</h2>
      <button>⭐</button>
      <button>❤️</button>
      <button>❌</button>
    </div>
    <div class="track">
      <h2>Puppy Love (Ft. Jagged Edge & Jermaine Dupri)</h2>
      <button>⭐</button>
      <button>❤️</button>
      <button>❌</button>
    </div>
    <div class="track">
      <h2>You Know Me (Ft. Da Brat & Jermaine Dupri)</h2>
      <button>⭐</button>
      <button>❤️</button>
      <button>❌</button>
    </div>
    <div class="track">
      <h2>The Dog in Me</h2>
      <button>⭐</button>
      <button>❤️</button>
      <button>❌</button>
    </div>
    <div class="track">
      <h2>Bow Wow (That's My Name) (Ft. Snoop Dogg)</h2>
      <button>⭐</button>
      <button>❤️</button>
      <button>❌</button>
    </div>
  </div>

<h2>Example 3</h2>
<div class="controls">
    <button>⏯️</button>
    <button>🐢</button>
    <button>🐰</button>
    <div class="scrubber"></div>
    <button>💬</button>
    <button>🔽</button>
  </div>

<h2>Example 4</h2>
<div class="hero">
  <h2>Something Big Is Coming</h2>
  <p>Get Ready...</p>
</div>

<h2>Example 5</h2>
<div class="corners">
  <div class="corner item">1</div>
  <div class="corner item">TWO</div>
  <div class="corner item">3</div>
  <div class="corner item">4</div>
</div>

<h2>Example 6</h2>
<div class="stacked">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
  <div class="item">5</div>
</div>
  
<h2>Example 7</h2>
 <div class="container known">
    <div class="item">Short</div>
    <div class="item">Longerrrrrr</div>
    <div class="item">
      <img src="https://source.unsplash.com/300x200" alt="">
    </div>
    <div class="item">💩</div>
  </div>

<h2>Example 8</h2>
<button onClick="addItem()">+ Add</button>
<div class="unknown">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
</div>

<h2>Example 9</h2>
<div class="flex-container">
  <div class="item">Short</div>
  <div class="item">Longerrrrrrrrrrrrrr</div>
  <div class="item">💩</div>
  <div class="item">This is Many Words</div>
  <div class="item">Lorem, ipsum.</div>
  <div class="item">10</div>
  <div class="item">Snickers</div>
  <div class="item">Wes Is Cool</div>
  <div class="item">Short</div>
</div>
              
            
!

CSS

              
                :root {
  --yellow: #ffc600;
}

.flipper {
  display: grid;
  grid-gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
}

.flipper.flip {
  grid-template-columns: 1fr;
}

.item {
  display: grid;
  justify-content: center;
  align-items: center;
  border: 5px solid rgba(0, 0, 0, 0.03);
  border-radius: 3px;
  font-size: 35px;
  background-color: var(--yellow);
}

.item p {
  margin: 0 0 5px 0;
}

.track {
  background: white;
  padding: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-flow: column;
}


.controls {
  margin: 200px 0;
  /* display: flex; */
  /* align-items: center; */
  display: grid;
  grid-template-columns: auto auto auto 1fr auto auto;
}

.scrubber {
  background: #BADA55;
  height: 10px;
  min-width: 100px;
  border-radius: 10px;
  /* flex: 1; */
}

.hero {
  height: 200px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid red;
  display: grid;
  justify-items: center;
  align-content: center;
  /* display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; */
}

.corners {
  display: grid;
  height: 200px;
  width: 200px;
  border: 10px solid var(--yellow);
  grid-template: 1fr 1fr / 1fr 1fr;
  align-items: end;
  justify-items: end;
}


.corner:nth-child(1),
.corner:nth-child(2) {
  align-self: start;
}

.corner:nth-child(1),
.corner:nth-child(3) {
  justify-self: start;
}

.stacked {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  margin-top: 20px;
}

.stacked>* {
  width: 30%;
  margin-bottom: 20px;
}

.known {
  display: grid;
  margin: 20px 0;
  grid-template-columns: repeat(4, 1fr);
  justify-content: center;
  grid-gap: 20px;
}

.unknown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  grid-gap: 20px;
}

.flex-container {
  display: flex;
  flex-wrap:wrap;
}

.flex-container>* {
  flex: 1;
  margin: 10px;
}
              
            
!

JS

              
                function flip(e) {
  const flipper =     document.querySelector('.flipper');
  flipper.classList.toggle('flip');
}

function addItem() {
  const unknown = document.querySelector('.unknown');
  unknown.innerHTML += `<div class="item">${unknown.childElementCount}</div>`;
}
              
            
!
999px

Console