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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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="row-lines">
  <article>
    <figure></figure>
    <p>The grid container here has a class of <code>row-lines</code> applied to implement a workaround to achieve the desired effect, but a way to do it intrinsically with grid woud be preferred.</p>
  </article>

  <article>
    <figure></figure>
    <p>The desired effect is a line appearing only between the grid <strong>rows</strong>, and extending <em>unbroken</em> across the column gaps.</p>
  </article>
  
  <article>
    <figure></figure>
    <p>I’d be happy for the width of the line to be centred within the width of the row gap, but it would be amazing if its vertical alignment within the gap could be specified.</p>
  </article>

  <article>
    <figure></figure>
    <p>Note that I don’t want a line to appear above or beneath all rows, only in the gaps <em>between</em> rows.</p>
  </article>

  <article>
    <figure></figure>
    <p>The inverse of this could be desired whereby there are lines between columns but not rows. Or one could choose to have both, perhaps with different line widths for each axis.</p>
  </article>
    
  <article>
    <figure></figure>
    <p>Applying gutter lines with dedicated CSS properties would be way easier to author than the <code>:nth-child</code> selectors constrained by viewport width ranges which I’ve used to create the lines. If you have a better workaround, let me know <a href="https://twitter.com/schofeld">@schofeld</a>.</p>
  </article>
  
  <article>
    <figure></figure>
    <p>The lovely thing about grid-gap is that it effectively creates gutters analogous to <strong>margins</strong> <em>between</em> the child elements, as opposed to padding.</p>
  </article>

  <article>
    <figure></figure>
    <p>As a consequence one doesn't have to juggle with the effects of negative margins at the bounds of the container, which one does when using approaches like <a href="https://github.com/Heydon/fukol-grids">Fukol</a> to derive the same layout effect.</p>
  </article>
</div>

              
            
!

CSS

              
                div {
  width: 100%;
  display: grid;
  grid-template-columns: repeat( auto-fit, minmax(220px, 1fr) );
  grid-gap: 0 30px;
}

article {
  padding: 1.25em 0 1em;
  position: relative;
}

figure {
  background: #99c;
  height: 100px;
}

p {
  margin: 0.5em 0 0;
}

* {
  margin: 0;
  box-sizing: border-box;
}

body {
  margin: 0.75em 30px;
  font-family: sans-serif;
}

/* Row lines hack */

.row-lines > article::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100vw - 60px);
}

/* 1 column */
@media (max-width: 529px) {
  .row-lines > article:nth-child(1n+2)::after {
    border-top: 1px solid #ccc;
  }
}

/* 2 columns */
@media (min-width: 530px) 
and (max-width: 779px) {
  .row-lines > article:nth-child(2n+3)::after {
    border-top: 1px solid #ccc;
  }
}

/* 3 columns */
@media (min-width: 780px) 
and (max-width: 1029px) {
  .row-lines > article:nth-child(3n+4)::after {
    border-top: 1px solid #ccc;
  }
}

/* 4 columns */
@media (min-width: 1030px) 
and (max-width: 1279px) {
  .row-lines > article:nth-child(4n+5)::after {
    border-top: 1px solid #ccc;
  }
}

/* 5 columns */
@media (min-width: 1280px) 
and (max-width: 1529px) {
  .row-lines > article:nth-child(5n+6)::after {
    border-top: 1px solid #ccc;
  }
}

/* 6 columns */
@media (min-width: 1530px) 
and (max-width: 1779px) {
  .row-lines > article:nth-child(6n+7)::after {
    border-top: 1px solid #ccc;
  }
}

@media (min-width: 1780px) 
and (max-width: 2029px) {
  .row-lines > article:nth-child(7n+8)::after {
    border-top: 1px solid #ccc;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console