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

              
                <section class="demo-intro">
  <div class="container">
    <h1>An example of hard-to-maintain media queries</h1>
    <p>This is an example to show why we need container queries. <a href="https://utilitybend.com/blog/styling-based-on-container-width-made-possible-with-css-container-queries" target="_blank">Read more on my blog</a>.</p>
  </div>
</section>
<section class="grid container">
  <main class="content">
    <article class="card">
      <img src="https://picsum.photos/800/600?random=1" alt="" />
      <div class="card-body">
        
        <h2>Some rondom title in here</h2>
        <p class="card-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras convallis sodales erat vel accumsan.</p>
        <a href="">Read more</a>
      </div>
    </article>
    <article class="card">
      <img src="https://picsum.photos/800/600?random=2" alt="" />
      <div class="card-body">
        
        <h2>Some rondom title in here</h2>
        <p class="card-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras convallis sodales erat vel accumsan.</p>
        <a href="">Read more</a>
      </div>
    </article>
  </main>
  <aside class="sidebar">
    <article class="card">
      <img src="https://picsum.photos/800/600?random=3" alt="" />
      <div class="card-body">
        
        <h2>Some rondom title in here</h2>
        <p class="card-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras convallis sodales erat vel accumsan.</p>
        <a href="">Read more</a>
      </div>
    </article>
  </aside>
</section>
              
            
!

CSS

              
                /* Basic card styling */
.card {
  margin-bottom: 24px;
  border: 1px solid #444;
  background: rgba(25,35,51);
}

.card-body {
  padding: 15px;
}

/* container magic, make cards change look & feel based by their container width instead of the viewport */

.grid > * {
  contain: layout inline-size style;
}

@media (max-width: 560px) {
  .card {
    display: grid;
    gap: 15px;
    grid-template-columns: 100px 1fr;
    padding: 15px;
    align-items: center;
  }

  .card .card-body {
    padding: 0;
  }
  .card-description {
    display: none;
  }
}

@media (min-width: 700px) and (max-width: 799px) {
  .content .card {
    display: grid;
    gap: 15px;
    grid-template-columns: 200px 1fr;
    padding: 15px;
    align-items: center;
  }

  .content .card .card-body {
    padding: 0;
  }
}

@media (min-width: 800px) {
  .grid {
    display: grid; 
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 24px;
  }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: 1fr 400px;
  }
    
  .content .card {
    display: grid;
    gap: 15px;
    grid-template-columns: 200px 1fr;
    padding: 15px;
    align-items: center;
  }

  .content .card .card-body {
    padding: 0;
  }
}

@media (min-width: 900px) and (max-width: 1100px) {
  .content .card .card-description {
    display: none;
  }
}

/* some basic styling (added to the bottom for convenience) */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Lato', sans-serif;
  font-size: 1.2rem;
  line-height: 1.5;
  color: #FEFEFE;
  background: #1f2937;
}

img {
  max-width: 100%;
  margin: 0;
}

h1 {
  margin: 0 0 16px 0;
  font-family: 'Merriweather', serif;
  font-size: 2rem;
}

h2 {
  margin: 0 0 8px 0;
  font-family: 'Merriweather', serif;
  font-size: 1.5rem;
}

p {
  margin: 0 0 24px 0;
}

.demo-intro {
  font-size: 1.5rem;
  background: #111827;
}

.demo-intro p {
  margin: 0;
}

a {
  color: darkorange;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 40px 20px;
}
              
            
!

JS

              
                
              
            
!
999px

Console