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

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="correct">
  <div>correct</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

<div class="bootstrap">
  <div class="row">
    <div class="col-sm-7"><span>bootstrap</span></div>
    <div class="col-sm-1"><span>2</span></div>
    <div class="col-sm-1"><span>3</span></div>
    <div class="col-sm-1"><span>4</span></div>
    <div class="col-sm-1"><span>5</span></div>
    <div class="col-sm-1"><span>6</span></div>
  </div>
</div>

<div class="lost">
  <div>lost</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

<div class="negative-margin-grid">
  <div>lost masonry</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

<div class="knowing-number-of-els-per-row">
  <div>els per row</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

<div class="grid-spec">
  <div>grid spec</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

<div class="figure-out-wtf-grid-spec-is-doing">
  <div>what grid spec is doing</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>
              
            
!

CSS

              
                @use lost;

:root {
  padding: 30px;
}

/* "Switches" to turn grids on and off, and compare them with the correct gutterless grid. Just comment/uncomment these. */
.lost {
  display: none !important;
}

.bootstrap {
  display: none !important;
}

.negative-margin-grid { /* Bootstrappy grids */
  display: none !important;
}

.knowing-number-of-els-per-row { /* Correct solution */
/*   display: none !important; */
}

.grid-spec {
/*   display: none !important; */
}

/* Common misc styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: sans-serif;
  background: rgba(0,0,255,.05);
}

:root {
  overflow-x: hidden;
}

.bootstrap {
  margin-bottom: 5px;
}

.bootstrap [class*="col"] span {
  display: block;
  border: 1px solid rgba(0,0,255,.25);
}

.lost div,
.correct div,
.knowing-number-of-els-per-row div,
.negative-margin-grid div,
.grid-spec div,
.figure-out-wtf-grid-spec-is-doing div,
.nine60 div {
  border: 1px solid rgba(0,0,255,.25);
  margin-bottom: 5px;
}

/* Correct - Gutterless so it's impossible to mess up the math. */
.correct {
  display: flex;
}

.correct div {
  width: calc(100% * 1/12);
}

.correct div:nth-child(1) {
  width: calc(100% * 7/12);
}

/* Lost */
.lost {
  lost-utility: clearfix;
}

.lost div {
  lost-column: 1/12 6 30px;
}

.lost div:nth-child(1) {
  lost-column: 7/12 6 30px;
}

/*
  Negative Margin grid (a la Bootstrap 2, although Bootstrap 3's padding grid is the same broken concept)
  ----------------------------------------
  The extra space on the left/right of the container is unaccountable, so there is no symmetry with the correct grid.
*/
.negative-margin-grid {
  display: flex;
  margin: 0 -15px;
}

.negative-margin-grid div {
  width: calc(100% * 1/12 - 30px);
  margin: 0 15px 5px;
}

.negative-margin-grid div:nth-child(1) {
  width: calc(100% * 7/12 - 30px);
}

/*
  Knowing Number of Elements per Row
  ----------------------------------
  Notice the outwards-in symmetry between the beginning and ends of columns. This type of symmetry doesn't exist in any grid system.

  In my opinion, if you're using gutters (you should be), this is correct.
*/
.knowing-number-of-els-per-row {
  display: flex;
}

.knowing-number-of-els-per-row div {
  width: calc(100% * 1/12 - (30px - 30px / 6));
  margin-right: 30px;
}

.knowing-number-of-els-per-row div:nth-child(1) {
  width: calc(100% * 7/12 - (30px - 30px / 6));
}

.knowing-number-of-els-per-row div:last-child {
  margin-right: 0;
}

/*
  Grid spec
  ---------
  I'm pretty sure this is broken. It doesn't seem like there's any symmetry here.
*/
.grid-spec {
  display: grid;
  grid-template-columns: 7fr 1fr 1fr 1fr 1fr 1fr;
  grid-column-gap: 30px;
}

/* Wtf is it doing? */
.figure-out-wtf-grid-spec-is-doing {
  display: flex;
}

.figure-out-wtf-grid-spec-is-doing div {
  width: calc(100% * 1/12);
  margin-right: 30px;
}

.figure-out-wtf-grid-spec-is-doing div:first-child {
  width: calc(100% * 7/12);
}

.figure-out-wtf-grid-spec-is-doing div:last-child {
  margin-right: 0;
}
              
            
!

JS

              
                
              
            
!
999px

Console