cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="page grid">
  <header class="grid">
    <h1 class="span-5-8">Fluid Layout Preview</h1>
    <p class="span-3-8"><a href="http://justifygrid.com">Justify Grid</a></p>
  </header>
  <img class="span-5-8 push-3-8" src="http://justifygrid.com/images/customize.png" alt=""/>
  <form id="builder" class="span-3-8 pull-5-8">
    <label><span>Number of columns</span> <input type="text" name="columns" value="12" /></label>
    <label><span>Column width (em)</span> <input type="text" name="column"  value="4"  /></label>
    <label><span>Gutter width (em)</span> <input type="text" name="gutter"  value="2.5"/></label>
    <button class="btn" type="submit">Preview!</button>
  </form>
</div>
<div id="preview">
  <p class="learn-more">Learn more about <a href="http://justifygrid.com">Justify Grid</a></p>
</div>
            
          
!
            
              html, body {
  padding: 0;
  margin: 0;
  color: #fff;
  font: 300 100%/1.5 'Open Sans', sans-serif;
}
html {
  min-height: 100%;
  background-color: #8495a5;
  background-image:
    -webkit-linear-gradient(top, rgba(181,191,201,0.5), rgba(79,89,99,0.5)),
    -webkit-radial-gradient(center top, rgba(132,149,165,0.6), #8495a5 80%),
    -webkit-linear-gradient(top, #ffffff 1px, transparent 1px),
    -webkit-linear-gradient(left, #ffffff 1px, transparent 1px);
  background-image:
    -moz-linear-gradient(top, rgba(181,191,201,0.5), rgba(79,89,99,0.5)),
    -moz-radial-gradient(center top, rgba(132,149,165,0.6), #8495a5 80%),
    -moz-linear-gradient(top, #ffffff 1px, transparent 1px),
    -moz-linear-gradient(left, #ffffff 1px, transparent 1px);
  background-image:
    -o-linear-gradient(top, rgba(181,191,201,0.5), rgba(79,89,99,0.5)),
    -o-radial-gradient(center top, rgba(132,149,165,0.6), #8495a5 80%),
    -o-linear-gradient(top, #ffffff 1px, transparent 1px),
    -o-linear-gradient(left, #ffffff 1px, transparent 1px);
  background-image:
    linear-gradient(to bottom, rgba(181,191,201,0.5), rgba(79,89,99,0.5)),
    radial-gradient(at center top, rgba(132,149,165,0.6), #8495a5 80%),
    linear-gradient(to bottom, #ffffff 1px, transparent 1px),
    linear-gradient(to right, #ffffff 1px, transparent 1px);
  background-attachment: fixed;
  background-size: auto, auto, 1em 1em, 1em 1em;
  background-position: 0 -1px;
}
body {
  margin: 0 1em;
}


.page, .learn-more {
  max-width: 49.5rem;
  margin: 0 auto;
}
.page > header > h1, .page > header > p {
  margin: 0;
  color: #fff;
  font: 700 1.5rem/1.3 'Josefin Slab', serif;
  text-shadow: 0.05em 0.05em 0.1em rgba(0, 0, 0, 0.4);
}
.page > header > p {
  text-align: right;
}
.page > header > p a {
  text-decoration: none;
}


.btn {
  display: inline-block;
  padding: 0.4em 1em;
  border: 0;
  margin: 1em 0;
  border-radius: 0.25em;
  background-color: #8495a5;
  background-image: -webkit-linear-gradient(top, #9caab7, #697784);
  background-image:    -moz-linear-gradient(top, #9caab7, #697784);
  background-image:      -o-linear-gradient(top, #9caab7, #697784);
  background-image:   linear-gradient(to bottom, #9caab7, #697784);
  color: #fff;
  font-size: 1.25em;
  font-weight: 400;
  text-align: center;
  text-decoration: none;
}
.btn:focus, .btn:hover {
  box-shadow:
    inset 0 0 0.5em rgba(255, 255, 255, 0.5),
    0.1em 0.1em 0.2em rgba(0, 0, 0, 0.25);
}
.btn:active {
  box-shadow:
    inset 0 0 0.5em rgba(255, 255, 255, 0.5),
    0.05em 0.05em 0.1em rgba(0, 0, 0, 0.25);
}


#builder {
  margin: 0;
  text-align: center;
}


a {
  color: #fff;
}
img {
  display: block;
  width: 100%;
}
label > span, input, button {
  box-sizing: border-box;
}
label {
  display: block;
  margin: 0 0 0.25em;
  text-align: left;
}
input, button {
  vertical-align: baseline;
  padding: 0.25em;
  border: none;
  margin: 0;
  color: #fff;
  font: 300 100%/1.2 'Open Sans', sans-serif;
}
input[type="text"] {
  width: 100%;
  border: 1px solid #ccc;
  color: #333;
}
button {
  -webkit-appearance: none;
  cursor: pointer;
}


::-moz-selection {
  background: #8495a5;
  color: #fff;
  text-shadow: none;
}
::selection {
  background: #8495a5;
  color: #fff;
  text-shadow: none;
}


/* Justify Grid's base CSS */
.grid {
  text-align: justify !important;
  text-justify: distribute-all-lines;
  font-size: 0 !important;
}
.grid:after {
  content: "";
  display: inline-block;
  width: 100%;
}
.grid > * {
  vertical-align: top;
  display: inline-block;
  width: 100%;
  text-align: left;
  font-size: medium;
}
[class*="push-"], [class*="pull-"] {
  position: relative;
}


@media screen and (min-width: 30em) {
  /* Nested grids not available in this demo */
  .span-3-8 { width: 34.34343%; }
  .span-5-8 { width: 60.60606%; }
  .push-3-8 { left:  39.39394%; }
  .pull-5-8 { left: -65.65657%; }

  .page > header > h1, .page > header > p {
    font-size: 1.75rem;
  }
  img {
    margin-top: 1.5em;
  }
}
@media screen and (min-width: 48em) {
  .page > header > h1, .page > header > p {
    font-size: 2.5rem;
  }
}
            
          
!
            
              /*
 * Download your customized CSS at:
 * http://justifygrid.com/#customize
 * including push, pull, prepend and append classes
 *
 * Created by:
 * https://twitter.com/CrocoDillon
 *
 * Original JS at:
 * http://justifygrid.com/js/builder.js
 */

(function(d){
  var   form          = d.forms.builder,
        outputElement = d.getElementById('preview'),
        outputHtml;

  form.onsubmit = function(e) {
    e = e || event;
    (e.preventDefault) ? e.preventDefault() : e.returnValue = false;

    var i,
        n           = parseInt(form.columns.value),
        columnWidth = parseFloat(form.column.value),
        gutterWidth = parseFloat(form.gutter.value),
        totalWidth  = n * columnWidth + (n - 1) * gutterWidth;

    if (n < 1 ||
        columnWidth <= 0 ||
        gutterWidth <= 0) {
      outputElement.innerHTML = '<p style="text-align:center">Awww... you broke the grid!  (╯°□°)╯  ┻┻</p>';
      return;
    }

    function generateSpan(span) {
      var width = 100 * (span * columnWidth + (span - 1) * gutterWidth) / totalWidth;
      width = width.toFixed(6).replace(/\.?0+$/, '');
      
      return '<div style="width:' + width + '%;margin-bottom:1em;background:#a7cd80;white-space:pre">&nbsp;.span-' + span + '</div>';
    }
    
    outputHtml = '<div class="grid" style="overflow-x:hidden;max-width:' + totalWidth + 'rem;margin:0 auto;color:#333;font-family:Consolas, Monaco, \'Andale Mono\', monospace;line-height:3">';
    
    // first line of inline-blocks, each spans 1 column
    for (i = 1; i <= n; i++) {
      outputHtml += generateSpan(1) + ' ';
    }
    // other lines, each with 2 inline-blocks of every possible span
    i = n - 1;
    while(i >= n / 2) {
      outputHtml += generateSpan(i) + ' ';
      outputHtml += generateSpan(n - i) + ' ';
      i--;
    }
    
    outputHtml += '</div>';

    form.columns.value = n;
    form.column.value  = columnWidth;
    form.gutter.value  = gutterWidth;

    outputElement.innerHTML = outputHtml;
  }
})(document);
            
          
!
999px
Loading ..................

Console