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

              
                
<h1>Columns</h1>

<pre>grid-template-columns: auto 10% auto</pre>

<ol>
  <li>
    <p>While computing the intrinsic width the percentage column is treated as <code>auto</code>.</p>
    <p>The intrinsic width is: 492px.</p>
  </li>
  <li>
    <p>During layout the 10% is resolved to 49px.</p>
    <p>And the track sizing algorithm is run like if you have "<code>grid-template-columns: auto 49px auto</code>".</p>
</ol>

<p>Current output is the same in all browsers (the percentage is treated as <code>auto</code> during intrinsic size computation and resolved during layout):</p>

<div class="grid columns">
  <div class="i1" style="grid-column: 1; grid-row: 1;">Testing</div>
  <div class="i2" style="grid-column: 3; grid-row: 2;">Testing</div>
  <div class="i3" style="grid-column: 1 / span 3; grid-row: 3;">Testing this thing with a quite long line</div>
</div>

<hr>


<h1>Rows</h1>

<pre>grid-template-rows: auto 10% auto</pre>

<ol>
  <li>
    <p>There's no intrinsic height computation phase.</p>
  </li>
  <li>
    <p>During layout the 10% is treated as <code>auto</code>.</p>
    <p>The <em>intrinsic</em> height is 140px. In order to calculate this the track sizing algorithm is already run one time for the rows.</p>
    <p>Then it's supposed that we resolve the 10% percentage to 14px.</p>
    <p>If we want to do that, we need to rerun the algorithm with "<code>auto 14px auto</code>" or we'll have overflow.</p>
</ol>

<p>With just one pass of the track sizing algorithm the output would be something like this:</p>

<div class="grid rows pass-1">
  <div class="i1" style="grid-column: 1; grid-row: 1;">Testing</div>
  <div class="i2" style="grid-column: 2; grid-row: 3;">Testing</div>
  <div class="i3" style="grid-column: 3; grid-row: 1 / span 3;">Testing this thing with a quite long line</div>
</div>

<p>This is because during that 1st pass we got as sizes 20px 100px 20px, and then we resolve the 10% track against 140px (14px). So we resize the 2nd row to 14px and we don't do anything else.</p>

<p>If we do an extra pass we could get the expected output (similar to what we get for columns):</p>

<div class="grid rows pass-2">
  <div class="i1" style="grid-column: 1; grid-row: 1;">Testing</div>
  <div class="i2" style="grid-column: 2; grid-row: 3;">Testing</div>
  <div class="i3" style="grid-column: 3; grid-row: 1 / span 3;">Testing this thing with a quite long line</div>
</div>


<p>Current output is the same in all browsers (the percentage is treated as <code>auto</code> and never resolved later):</p>

<div class="grid rows">
  <div class="i1" style="grid-column: 1; grid-row: 1;">Testing</div>
  <div class="i2" style="grid-column: 2; grid-row: 3;">Testing</div>
  <div class="i3" style="grid-column: 3; grid-row: 1 / span 3;">Testing this thing with a quite long line</div>
</div>
              
            
!

CSS

              
                
.grid {
  font: 20px/1 Monospace;
  display: inline-grid;
  border: solid thick;
}

.columns {
  grid-template-columns: auto 10% auto;
  grid-template-rows: 50px 50px 50px;
}

.rows {
  grid-template-columns: 100px 100px 100px;
  grid-template-rows: auto 10% auto;
}

.pass-1 {
  grid-template-rows: 20px 14px 20px;
  margin-bottom: 80px;
}

.pass-2 {
  grid-template-rows: auto 14px auto;
}

.i1 {
  background: magenta;
}

.i2 {
  background: cyan;
}

.i3 {
  background: yellow;
}

              
            
!

JS

              
                
              
            
!
999px

Console