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 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

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

              
                <main>
    <section class="container-wide">
  <h4 class="support"></h4>
  </section>
  <h2>Container max-width: 700px</h2>
  <p>Looks good on wider resolutions only if container queries are supported in browser.</p>
  <section class="container-wide resizeable">
    <article class="card">
      <div class="card__wrapper">
        <figure>
          <img class="card__image" src="https://picsum.photos/id/2/500/500" />
        </figure>
        <div>
          <h3 class="card__title">This is an item title</h3>
          <div>
            <p>
              <small class="card__description">
                This is an item description. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque convallis ultrices nisl eget dapibus. Aliquam auctor mi sed porttitor lacinia. In condimentum tempus aliquam.</small>
            </p>
          </div>
          <div class="card__actions">
            <strong class="card__price">$2,000</strong>
            <button class="card__button">Add to cart</button>
          </div>
        </div>
      </div>
    </article>
  </section>

  <h2>Container max-width: 380px</h2>
  <section class="container-narrow resizeable">
    <article class="card">
      <div class="card__wrapper">
        <figure>
          <img class="card__image" src="https://picsum.photos/id/2/500/500" />
        </figure>
        <div>
          <h3 class="card__title">This is an item title</h3>
          <div>
            <p>
              <small class="card__description">
                This is an item description. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque convallis ultrices nisl eget dapibus. Aliquam auctor mi sed porttitor lacinia. In condimentum tempus aliquam.</small>
            </p>
          </div>
          <div class="card__actions">
            <strong class="card__price">$2,000</strong>
            <button class="card__button">Add to cart</button>
          </div>
        </div>
      </div>
    </article>
  </section>
</main>
              
            
!

CSS

              
                body {
  margin: 0 auto;
  line-height: 1.4;
  font-size: 18px;
  padding: 0 1em;
}

h2 {
  margin: 1em 0 0.5em;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

figure {
  margin: 0;
}

.card {
  contain: layout inline-size style;
}

.card__title {
  margin: 0 0 1em;
}

.card__wrapper {
  display: grid;
  grid-gap: 1.5em;
  grid-template-rows: auto auto;
  background: #e7e7e7;
  padding: 1em;
  border-radius: 0.5em;
  margin-bottom: 1em;
}

.card__image {
  object-fit: cover;
  object-position: center;
  width: 100%;
  height: 150px;
  border-radius: 0.5em;
  overflow: hidden;
}

.card__actions {
  display: grid;
  grid-gap: 1em;
  grid-template-columns: auto auto;
  align-items: center;
}

.card__price {
  font-size: 1.25em;
  display: inline-block;
  background-color: rgba(0, 0, 0, 0.15);
  text-align: center;
  padding: 0.15em;
}

.card__description {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card__button {
  border-radius: 0;
  border: 0;
  background-color: darkred;
  color: #fff;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.5em;
}

.resizeable {
  resize: horizontal;
  overflow: auto;
  width: 700px;
}

.container-wide {
  min-width: 320px;
  max-width: 700px;
}

.container-narrow {
  width: 350px;
  min-width: 320px;
  max-width: 700px;
}

@container (min-width: 568px) {
  .card__wrapper {
    align-items: center;
    grid-gap: 1.5em;
    grid-template-rows: auto;
    grid-template-columns: 150px auto;
  }

  .card__image {
    min-width: auto;
    height: auto;
  }
}

.support {
  contain: layout inline-size style;
}

.support::after {
  content: "Container queries are not supported in your browser. Elements won't adapt to container resize. First element won't have wide container styles applied to it.";
  display: block;
    font-size: 14px;
    background: darkred;
  color: white;
  font-weight: 400;
  padding: 1em 2em;
}

@container (min-width: 0px) {
  .support::after {
     background: darkgreen;
    content: "Container queries are supported in your browser. Both elements will adapt to container dimension changes.";
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console