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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="grid">
  <div class="item">
    <div class="subitem"></div>
  </div>
</div>




<div class="notes">
  <h2>Notes:</h2>
  <ul>
    <li>Make sure to view this in Firefox 71+.</li>
    <li>tl;dr: not just items but subitems are aligned to the parent .grid.</li>
    <li>.grid (orange background): has 9 columns (column lines 1–10), and 4 rows (row lines 1–5)</li>
    <li>.item (green background) is a grid child and set to span column lines 2–8 and row lines 2–4 of .grid which means it occupies 6 of .grid’s 9 cols and 2 of its 4 rows.
</li>
    <li>.item is <em>also</em> set to display: grid which gives it its own columns and rows however rather than defining new track definitions for those, it sets both to subgrid. This means that the columns and rows of .item snap to the same dimensions as .grid’s rows and cols, although .item’s line numbers restart from '1'.</li>
    <li>.subitem (indigo background) is a grid child of .item and set to span .item’s column lines 3–6 (so 3 of a possible 6) and row lines 1–3 (so all of the possible 2).</li>
</ul>
</div>
              
            
!

CSS

              
                .grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(4, minmax(100px, auto));
  
  border: 2px solid red;
  border-radius: 5px;
  background-color: orange;
}

.item {
  display: grid;
  grid-column: 2 / 8; /* these refer to line nos, not cols! */
  grid-row: 2 / 4;
  grid-template-columns: subgrid;
  grid-template-rows: subgrid;
  
  border: 2px solid yellow;
  border-radius: 5px;
  background-color: green;
  color: white;
}

.subitem {
  grid-column: 3 / 6;
  grid-row: 1 / 3;
  
  border: 2px solid brown;
  border-radius: 5px;
  background-color: indigo;
  color: white;
}

body {
  color: white;
  font-family: Georgia;
  line-height: 1.3;
}

.notes {
 color: #222; 
 width: 40em;
 margin: 1.5em auto 0;
}

.notes li {
  margin-top: 1.5em;
}
              
            
!

JS

              
                
              
            
!
999px

Console