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="grid-breakout">
  <section class="full bg-offset pad">
    <div class="header-flex">
      <h1>Fluid Breakout Layout with CSS Grid</h1>
      <p class="no-shrink">(DEMO 1 of 3)</p>
    </div>
    <p>Setting up the grid.</p>
    <a class="btn" href="https://www.viget.com/articles/fluid-breakout-layout-css-grid/" role="button" draggable="false">Read the article at Viget.com &rarr;</a>
  </section>
  <p><strong>(Because this has no column class, it defaults to 'content' size).</strong> Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi praesentium dicta cupiditate incidunt, in eius similique pariatur corrupti voluptatum minima! Vel provident corrupti odit placeat nesciunt deleniti officiis magnam quo?</p>
  <section class="feature bg-minimal pad">
    <h2>A Feature Breakout</h2>
    <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus vero eligendi aliquam, debitis, eum quidem amet neque iste tempore libero deleniti nesciunt! Magnam ullam nesciunt facere animi quas dolores quod.</p>
  </section>
  <section class="content">
    <h2>More Content</h2>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint eaque, amet optio magnam quibusdam assumenda laborum modi voluptatem a reprehenderit cumque, omnis, iusto alias magni. Amet non aliquam necessitatibus. Ducimus?</p>
  </section>
  <section class="popout bg-offset pad">
    <h2>A Popout Breakout</h2>
    <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus vero eligendi aliquam, debitis, eum quidem amet neque iste tempore libero deleniti nesciunt! Magnam ullam nesciunt facere animi quas dolores quod.</p>
  </section>
</main>
              
            
!

CSS

              
                /* Column measurements */
:root {
  --gap: clamp(1rem, 4vw, 2rem);
  --full: minmax(var(--gap), 1fr);
  --content: min(clamp(30rem, 52vw, 60rem), 100% - var(--gap) * 2);
  --popout: minmax(0, 2rem);
  --feature: minmax(0, 12vw);
}

/* Grid definition */
.grid-breakout {
  display: grid;
  grid-template-columns:
    [full-start] var(--full)
    [feature-start] var(--feature)
    [popout-start] var(--popout)
    [content-start] var(--content) [content-end]
    var(--popout) [popout-end]
    var(--feature) [feature-end]
    var(--full) [full-end];
}

/* Column assignments */
.grid-breakout > * {
  grid-column: content;
}

.full {
  grid-column: full;
}

.feature {
  grid-column: feature;
}

.popout {
  grid-column: popout;
}

.content {
  grid-column: content;
}

/* ↓ = For demo purposes - not necessary for the layout, just for looks ;) */

*,
*:before,
*:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Nunito Sans", sans-serif;
  line-height: 1.5;
  font-size: clamp(1rem, 0.5vw + 0.8rem, 1.25rem);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 900;
  line-height: 1.1;
  text-wrap: pretty;
}

h1 {
  text-wrap: balance;
}

.header-flex {
  display: flex;
  flex-direction: column;
  margin-block-end: 1rem;
}

@media (min-width: 700px) {
  .header-flex {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
}

.no-shrink {
  flex-shrink: 0;
}

.grid-breakout > * + * {
  margin-top: 2rem;
}

.pad {
  padding: var(--gap);
}

.bg-offset {
  background-color: #294d8b;
  color: #fff;
}

.bg-minimal {
  background-color: #ede7e4;
}

.btn {
  border-radius: 0.5em;
  border: 2px solid currentColor;
  color: #fff;
  display: inline-block;
  padding: 0.375em 0.75em;
  font-weight: 700;
  text-decoration: none;
  transition: color 250ms ease-in-out, border 250ms ease-in-out;
  margin-block-start: 1rem;
}

.btn:hover,
.btn:focus-visible {
  color: #1296bd;
}

              
            
!

JS

              
                    
              
            
!
999px

Console