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

              
                <div class="card card--min">
  <header class="card__header">
    Min
  </header>
  <div class="card__body">
    <p>Imagine that we want this card to occupy 70% of the width on small screens, but never to be bigger than 700px.
    <p>We can do:</p>
    <pre><code class="lang-css">
  width: 70%;
  max-width: 700px;
    </code></pre>
    <p>
      We can simplify using: <span class="code"></span>
    </p>
    <pre><code class="lang-css">
  min(700px, 70%);
    </code></pre>
    <p><em>You can add as many values as you whan't (if it has sense). Usually all with different units. The order does not matter.</em></p>
  </div>
</div>

<div class="card card--max">
  <header class="card__header">
    Max
  </header>
  <div class="card__body">
    <p>Imagine that we want this card to occupy 200px on small screens, but when we make the screen big enough, it has to occupy the 30% of the screen.</p>
    <p>We can do:</p>
    <pre><code class="lang-css">
  width: 30%;
  mix-width: 200px;
    </code></pre>
    <p>
      We can simplify using:
    </p>
    <pre><code class="lang-css">
  max(200px, 30%);
    </code></pre>
    <p><em>You can add as many values as you whan't (if it has sense). Usually all with different units. The order does not matter.</em></p>
  </div>
</div>

<div class="card card--clamp">
  <header class="card__header">
    Clamp
  </header>
  <div class="card__body">
    <p>Imagin that we want to have an element that occupies the 50% of the width, but never less than 300px nor more than 700px.</p>
    <p>We can do:</p>
    <pre><code class="lang-css">
  min-width: 300px;
  width: 50%;
  max-width: 700px;
    </code></pre>
    <p>
      We can simplify using: <span class="code"></span>
    </p>
    <pre><code class="lang-css">
  clamp(200px, 50%, 700px);
    </code></pre>
    <p><em>It works only with 3 values.</em></p>
  </div>
</div>

<div class="card">
    <header class="card__header">
        Interesting video (by Kevin Powell):
    </header>
  
    <div class="card__body">
      <iframe class="youtube" width="560" height="315" src="https://www.youtube.com/embed/U9VF-4euyRo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
    </div>
</div>

<div class="card card--warning">
  <header class="card__header">
    Warning
  </header>
  <div class="card__body">
    <p>I wouldn't recomend using it yet, it is too soon: <em>e.g.: Firefox ERS does not support min(), max() or clamp()</em>. Nevertheless, I think it is interesting to know how it works.
  </div>
</div>

<!-- I'm using prism for "prettier" code (syntax highlighting). See codepen settings. -->
              
            
!

CSS

              
                .card--min {
  width: min(700px, 70%);
}

.card--max {
  width: max(200px, 30%);
}

.card--clamp {
  width: clamp(300px, 50%, 700px);
}

/* Other stylings */
:root {
  --clr-primary: #ee6352;
  --clr-body: #333;
  --clr-bg: #ddd;
  --clr-bg-warning: #ffe0b1;
  --clr-shadow: #0003;
}
body {
  font-family: basic-sans, sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--clr-bg);
  color: var(--clr-body);
  
}

.card {
  margin: 3rem 0;
  background: white;
  padding: 2em;
  box-shadow: 0 3px 6px var(--clr-shadow);
  transition: box-shadow 0.1s ease-in-out;
}
.card:hover {
  box-shadow: 0 1px 2px var(--clr-shadow);
}

.card--warning {
  margin: 3rem;
  background: var(--clr-bg-warning);
}
.card__header {
  color: var(--clr-primary);
  font-size: 1.7rem;
  font-weight: 900;
  margin: 0 0 .5em;
  padding: 0;
}
.youtube {
  width: 100%;
}

.hidden {
  display: none;
}
              
            
!

JS

              
                
              
            
!
999px

Console