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>Examples from blog post: <a href="http://balcagia.duckdns.org:8080/blog/2018/08/10/grid-percent/">Changes on CSS Grid Layout in percentages and indefinite height</a></h1>

<h3>Example of percentage dimensions in a containing block with definite sizes</h3>

<div style="width: 500px; height: 200px; border: dashed thick black;">
  <div style="width: 50%; height: 75%; background: magenta;"></div>
</div>

<h3>Example of percentage margins in a containing block with definite sizes</h3>

<div style="width: 500px; height: 200px; border: dashed thick black;">
  <div style="margin-left: 10%; margin-top: 10%; height: 150px; background: magenta;"></div>
</div>

<h3>Example of intrisic width without constraints</h3>

<div style="float: left; font: 50px/1 Ahem;
            border: dashed thick black; background: magenta; color: cyan;">
  XX XXXXX
</div>

<hr>

<h3>Example of intrisic width with different constraints</h3>

<div style="width: 300px; border: thick dashed red; display: flow-root;">
  <div style="float: left; font: 50px/1 Ahem;
              border: solid thick black; background: magenta; color: cyan;">
    XX XXXXX
  </div>
</div>

<hr>

<div style="width: 100px; border: thick dashed red; display: flow-root;">
  <div style="float: left; font: 50px/1 Ahem;
              border: solid thick black; background: magenta; color: cyan;">
    XX XXXXX
  </div>
</div>

<h3>Example of percentage dimensions in a containing block with indefinite sizes</h3>

<div style="float: left;
            border: solid thick black; background: magenta;">
  <div style="width: 50%; height: 50%; background: cyan;">Hello world!</div>
</div>

<hr>

<h3>Example of percentage margins in a containing block with indefinite sizes</h3>

<div style="float: left; font: 50px/1 Ahem;
            border: solid thick black; background: magenta;">
  <div style="margin-left: 50%; height: 100px;
              background: cyan; color: blue;">XXXXX</div>
</div>

<hr>

<h3>Example of percentage tracks in a grid container with indefinite sizes</h3>

<div style="display: inline-grid; border: solid thick;
            grid-template-columns: 75%; grid-template-rows: 50%;">
  <div style="background: magenta;">Testing</div>
</div>

<h3>Example of percentage gutters in a grid container with indefinite sizes</h3>

<div style="display: inline-grid; grid-gap: 10%; border: solid thick;
            grid-template-columns: 200px 200px; grid-template-rows: 100px 100px;">
  <div style="background: magenta;"></div>
  <div style="background: cyan;"></div>
  <div style="background: yellow;"></div>
  <div style="background: lime;"></div>
</div>

<h3>Example of overlapping rows in the new behavior</h3>

<div style="display: grid; grid-template-rows: 25% 75%; border: solid thick;">
  <div style="background: magenta;">First<br>two lines</div>
  <div style="background: cyan;">Second</div>
</div>

<h3>Example of overflowing rows in the new behavior</h3>

<div style="display: grid; grid-template-rows: 50%; border: solid thick;">
  <div style="background: magenta;">First</div>
  <div style="background: cyan; height: 200px;">Second</div>
  <div style="background: yellow; height: 100px;">Third</div>
</div>

              
            
!

CSS

              
                hr {
  clear: both;
  border: none;
  height: 1em;
}
              
            
!

JS

              
                
              
            
!
999px

Console