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>
  <h2>Flexbox layout</h2>
  <article class="container fifty-fifty-flex">
    <section>
      <img src='https://images.unsplash.com/photo-1629824230786-1c212b964863?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDgxOTI0NTR8&ixlib=rb-4.0.3&q=80&w=500' alt='A super good pitbull doggo with cute squinting eyes, tongue hanging out, and a beaming smile stands in front of a reflective building wall that contains a random pattern of various blue-shaded squares'>
    </section>
    <section class="scroll-container">
      Lorem ipsum dolor sit, amet consectetur adipisicing elit. Veniam cupiditate explicabo autem voluptatem natus fuga, iste, dicta consectetur qui commodi nemo, quisquam minima doloremque aliquam reiciendis at dolorum eius esse. Lorem ipsum dolor sit amet consectetur adipisicing elit. Qui excepturi accusantium, voluptatem dolorem maiores possimus deleniti rerum adipisci iusto nobis consequatur reiciendis. Alias ipsa modi, ducimus esse molestiae nihil facilis? Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum natus libero amet? Alias autem ab commodi iusto enim. Unde eum asperiores nobis odio voluptate, enim culpa sit! Reprehenderit, soluta? Provident. Lorem ipsum dolor sit amet consectetur, adipisicing elit. A ducimus sunt consectetur quis ratione sapiente suscipit ullam aliquam inventore. Delectus eligendi numquam nisi at rem quia aliquam. Quaerat, magnam nemo! Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloremque fugit dolorem totam numquam culpa quo quos itaque similique in ratione incidunt recusandae perferendis dolore hic porro enim, obcaecati cumque ipsum. Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias amet atque delectus quia a labore, repellendus nemo inventore cumque fugit ea voluptas voluptates laborum! Praesentium, culpa qui! Ratione, maiores reprehenderit.
    </section>
  </article>

  <h2>Grid layout</h2>
  <article class="container fifty-fifty-grid">
    <section>
      <img src='https://images.unsplash.com/photo-1629824230786-1c212b964863?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDgxOTI0NTR8&ixlib=rb-4.0.3&q=80&w=500' alt='A super good pitbull doggo with cute squinting eyes, tongue hanging out, and a beaming smile stands in front of a reflective building wall that contains a random pattern of various blue-shaded squares'>
    </section>
    <section class="scroll-container">
      Lorem ipsum dolor sit, amet consectetur adipisicing elit. Veniam cupiditate explicabo autem voluptatem natus fuga, iste, dicta consectetur qui commodi nemo, quisquam minima doloremque aliquam reiciendis at dolorum eius esse. Lorem ipsum dolor sit amet consectetur adipisicing elit. Qui excepturi accusantium, voluptatem dolorem maiores possimus deleniti rerum adipisci iusto nobis consequatur reiciendis. Alias ipsa modi, ducimus esse molestiae nihil facilis? Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum natus libero amet? Alias autem ab commodi iusto enim. Unde eum asperiores nobis odio voluptate, enim culpa sit! Reprehenderit, soluta? Provident. Lorem ipsum dolor sit amet consectetur, adipisicing elit. A ducimus sunt consectetur quis ratione sapiente suscipit ullam aliquam inventore. Delectus eligendi numquam nisi at rem quia aliquam. Quaerat, magnam nemo! Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloremque fugit dolorem totam numquam culpa quo quos itaque similique in ratione incidunt recusandae perferendis dolore hic porro enim, obcaecati cumque ipsum. Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias amet atque delectus quia a labore, repellendus nemo inventore cumque fugit ea voluptas voluptates laborum! Praesentium, culpa qui! Ratione, maiores reprehenderit.
    </section>
  </article>
</main
              
            
!

CSS

              
                /* ---------------------------- 
Flexbox layout
---------------------------- */
.fifty-fifty-flex {
  display: flex;
  flex-wrap: wrap;
}

.fifty-fifty-flex > * {
  flex-grow: 1;
  flex-basis: var(--min-inline-size, 250px);
}

/* For flexbox layout, a min-height is needed on the scroll container to avoid collapsing completely when stacked */
.fifty-fifty-flex .scroll-container {
  min-height: 12rem;
}

/* ---------------------------- 
Grid layout
---------------------------- */
.fifty-fifty-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(var(--min-inline-size, 250px), 1fr)
  );

  /* This will ensure that both section sizes are the same whether stacked or split */
  grid-auto-rows: 1fr;
}

/* ---------------------------- 
Scroll section
---------------------------- */
.scroll-container {
  contain: size;
  overflow-y: auto;
}

/* ---------------------------- 
Demo styles
---------------------------- */
* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, sans-serif;
  font-size: clamp(1rem, 0.6rem + 1.125cqi, 1.125rem);
  line-height: 1.5;
  margin-block: 2rem;
  padding-inline: 2rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-block: 2rem 1rem;
}

.container {
  border: 1px dashed hotpink;
  max-width: 50rem;
}

.container img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  vertical-align: bottom;
}

.scroll-container {
  padding: 1rem;
}

              
            
!

JS

              
                
              
            
!
999px

Console