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

              
                <h2>Responsive Card Layout with Media Objects Made with Flexbox</h2>
<p>Use the buttons to add or remove cards to see how the layout behaves with different amounts of content.</p>
<button>Add Card</button> <button>Remove Card</button>

<main class="container">
  <div class="card">
    <div class="img"></div>
    <div class="content"><h3>Card Title</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
  </div>
  <div class="card">
    <div class="img"></div>
    <div class="content"><h3>Card Title</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
  </div>
  <div class="card">
    <div class="img"></div>
    <div class="content"><h3>Card Title</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
  </div>
  <div class="card">
    <div class="img"></div>
    <div class="content"><h3>Card Title</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
  </div>
  <div class="card">
    <div class="img"></div>
    <div class="content"><h3>Card Title</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
  </div>
  <div class="card">
    <div class="img"></div>
    <div class="content"><h3>Card Title</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
  </div>
  </div>
</main>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  font-size: 1.3em;
  padding: 0 1em 2em;
  line-height: 1.4;
  text-align: center;
}

h2 {
  margin: 14px 0;
  text-align: center;
}

.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  padding: 1em 0;
  text-align: left;
}

.card {
  width: 30%;
  display: flex;
  background: #eee;
  padding: .6em 1em .6em .6em;
  margin-bottom: 1em;
  border-radius: .3em;
  box-shadow: rgba(0, 0, 0, 0.2) 3px 6px 10px;
  border: solid 1px #ccc;
}

.img {
  min-width: 80px;
  height: 80px;
  border-radius: .3em;
  background: linear-gradient(to bottom, #d6c091 0%, #C05C9A 100%);
  opacity: .7;
  margin: 0 .6em 0 0;
  border: solid 1px firebrick;
}

.card h3 {
  margin: 0;
  font-size: 1em;
}

.content p {
  margin: 0;
  font-size: .7em;
  color: #222;
}

@media (max-width: 820px) {
  .container {
    min-width: auto;
    display: block;
  }
  .card {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .card {
    box-shadow: none;
  }
}
              
            
!

JS

              
                document.querySelector('button').addEventListener('click', function () {
  document.querySelector('main')
          .appendChild(document.querySelector('.card').cloneNode(true));
}, false);

document.querySelectorAll('button')[1].addEventListener('click', function () {
  if (document.querySelectorAll('.card')[1]) {
    document.querySelector('.card').remove();
  }
          
}, false);

              
            
!
999px

Console