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

              
                <main class="flow">
  <h1>Progressively enhanced card with container queries</h1>
  <p>The container query will only work in Chrome Canary right now. Make sure you enable the container queries flag in <strong>chrome://flags</strong>.</p>
  <p>When you are all set in canary, resize to see the card’s layout and styles change.</p>
  <article class="card">
    <div class="card__media">
      <img src="https://source.unsplash.com/F-B7kWlkxDQ/1200x675" alt="A turntable with a brigh orange vinyl on it" />
    </div>
    <div class="[ card__content ] [ flow ]">
      <h2>Join the Vinyl revolution</h2>
      <p>
        Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum
        nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum
        faucibus dolor auctor.
      </p>
      <a href="#" class="button">Find out more</a>
    </div>
  </article>
</main>
<hr />
<div class="flow">
  <h2>Container queries in a flexible layout</h2>
  <div class="auto-grid">
    <div>
      <article class="card">
        <div class="card__media">
          <img src="https://source.unsplash.com/F-B7kWlkxDQ/1200x675" alt="A turntable with a brigh orange vinyl on it" />
        </div>
        <div class="[ card__content ] [ flow ]">
          <h2>Join the Vinyl revolution</h2>
          <p>
            Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum
            nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum
            faucibus dolor auctor.
          </p>
          <a href="#" class="button">Find out more</a>
        </div>
      </article>
    </div>
    <div>
      <article class="card">
        <div class="card__media">
          <img src="https://source.unsplash.com/F-B7kWlkxDQ/1200x675" alt="A turntable with a brigh orange vinyl on it" />
        </div>
        <div class="[ card__content ] [ flow ]">
          <h2>Join the Vinyl revolution</h2>
          <p>
            Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum
            nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum
            faucibus dolor auctor.
          </p>
          <a href="#" class="button">Find out more</a>
        </div>
      </article>
    </div>
    <div>
      <article class="card">
        <div class="card__media">
          <img src="https://source.unsplash.com/F-B7kWlkxDQ/1200x675" alt="A turntable with a brigh orange vinyl on it" />
        </div>
        <div class="[ card__content ] [ flow ]">
          <h2>Join the Vinyl revolution</h2>
          <p>
            Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum
            nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum
            faucibus dolor auctor.
          </p>
          <a href="#" class="button">Find out more</a>
        </div>
      </article>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /* THE CONTAINER QUERY IS ON LINE 86 */

body {
  font-family: "Inter", sans-serif;
  max-width: 50rem;
  padding: 2rem 1.5rem;
  margin: 0 auto;
  color: #241623;
  background: #eef2f4;
}

main {
  contain: layout inline-size;
}

h1 {
  font-weight: 900;
  font-size: 3rem;
  line-height: 1.1;
}

h2 {
  font-weight: 900;
  font-size: 2.5rem;
  line-height: 1.1;
}

p {
  max-width: 60ch;
}

.card {
  --flow-space: 1rem;
  background: #ffffff;
  border-radius: 1em;
  overflow: hidden;
  box-shadow: 0 0 20px hsl(0 0% 0% / 10%);
  max-width: 30rem;
}

.card__content {
  padding: 1.5rem;
}

.card h2 {
  font-weight: 900;
  font-size: 1.8rem;
  line-height: 1.1;
}

.card__media {
  aspect-ratio: 16/9;
}

.button {
  display: inline-block;
  background: #8cfbde;
  color: #000000;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  letter-spacing: 0.03ch;
  text-transform: uppercase;
  border-radius: 0.8em;
}

.flow > * + * {
  margin-top: var(--flow-space, 1em);
}

hr {
  margin: 3em 0;
  border: unset;
  border-top: 1px solid #cccccc;
}

@supports (aspect-ratio: 16/9) {
  .card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

@container (min-width: 40em) {
  .card {
    display: flex;
    align-items: flex-start;
    max-width: unset;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: unset;
  }

  .card h2 {
    font-size: 2.5rem;
  }

  .card__media {
    aspect-ratio: 1/1;
    flex-basis: 30%;
    flex-shrink: 0;
  }

  .card__media img {
    border-radius: 0.5em;
  }

  .card__content {
    padding: 0;
  }
}

.auto-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 1rem;
}

.auto-grid > * {
  flex-basis: 40%;
  flex-grow: 1;
  contain: layout inline-size;
}

              
            
!

JS

              
                
              
            
!
999px

Console