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

              
                <main class="wrapper gridWrapper">
  <article>
    <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Nullam id dolor id nibh ultricies vehicula ut id elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam porta sem malesuada magna mollis euismod. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p><p><img src="http://placehold.it/80x100">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Etiam porta sem malesuada magna mollis euismod. Donec id elit non mi porta gravida at eget metus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam porta sem malesuada magna mollis euismod.</p>
  </article>
  <article>
    <p>Etiam porta sem malesuada magna mollis euismod. Maecenas faucibus mollis interdum. Curabitur blandit tempus porttitor. Donec ullamcorper nulla non metus auctor fringilla.<img src="http://placehold.it/80x100"></p><p>Nullam id dolor id nibh ultricies vehicula ut id elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
  </article>
</main>
              
            
!

CSS

              
                // Contents:
// 1. VAR & MIXIN SETUP
// 2. THE GRID SETUP
// 3. AUTHOR CUSTOM STYLES FOR LAYOUT

  
  
  
  
// 1. VAR & MIXIN SETUP  

//////////////////////////////////////////////////////////////////////////////
// Var: Flexible column width - Calc removes a fixed total gutter width //////
//////////////////////////////////////////////////////////////////////////////
$cW-1: calc(100% / 1 - ((1.5em * (1 - 1)) / 1))
$cW-2: calc(100% / 2 - ((1.5em * (2 - 1)) / 2))
$cW-3: calc(100% / 3 - ((1.5em * (3 - 1)) / 3))
$cW-4: calc(100% / 4 - ((1.5em * (4 - 1)) / 4))
$cW-5: calc(100% / 5 - ((1.5em * (5 - 1)) / 5))
$cW-6: calc(100% / 6 - ((1.5em * (6 - 1)) / 6))
$cW-7: calc(100% / 7 - ((1.5em * (7 - 1)) / 7))
$cW-8: calc(100% / 8 - ((1.5em * (8 - 1)) / 8))
$cW-9: calc(100% / 9 - ((1.5em * (9 - 1)) / 9))
$cW-10: calc(100% / 10 - ((1.5em * (10 - 1)) / 10))
$cW-11: calc(100% / 11 - ((1.5em * (11 - 1)) / 11))
$cW-12: calc(100% / 12 - ((1.5em * (12 - 1)) / 12))

//////////////////////////////////////////////////////////////////////////////
// Mixin: Initialise intended grid ///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Initialise 1 Column
@mixin colTotal-1
  grid-template-columns: $cW-1
// Initialise 2 Column
@mixin colTotal-2
  grid-template-columns: repeat(2, $cW-2 1.5em)
  // grid-template-columns: $cW-2 1.5em $cW-2
// Initialise 3 Column
@mixin colTotal-3
  grid-template-columns: repeat(3, $cW-3 1.5em)
// Initialise 4 Column
@mixin colTotal-4
  grid-template-columns: repeat(4, $cW-4 1.5em)
// Initialise 5 Column
@mixin colTotal-5
  grid-template-columns: repeat(5, $cW-5 1.5em)
// Initialise 6 Column
@mixin colTotal-6
  grid-template-columns: repeat(6, $cW-6 1.5em)
// Initialise 7 Column
@mixin colTotal-7
  grid-template-columns: repeat(7, $cW-7 1.5em)
// Initialise 8 Column
@mixin colTotal-8
  grid-template-columns: repeat(8, $cW-8 1.5em)
// Initialise 9 Column
@mixin colTotal-9
  grid-template-columns: repeat(9, $cW-9 1.5em)
// Initialise 10 Column
@mixin colTotal-10
  grid-template-columns: repeat(10, $cW-10 1.5em)
// Initialise 11 Column
@mixin colTotal-11
  grid-template-columns: repeat(11, $cW-11 1.5em)
// Initialise 12 Column
@mixin colTotal-12
  grid-template-columns: repeat(12, $cW-12 1.5em)

//////////////////////////////////////////////////////////////////////////////
// Mixin: Column Position - Horizontal Placement /////////////////////////////
// This property confuses me slightly, which is why I made it more descriptive
//////////////////////////////////////////////////////////////////////////////
// First Column
@mixin column-1
  grid-column: 1 / 2
// Second Column
@mixin column-2
  grid-column: 3 / 4
// Third Column
@mixin column-3
  grid-column: 5 / 6
// Forth Column
@mixin column-4
  grid-column: 7 / 8
// Fifth Column
@mixin column-5
  grid-column: 9 / 10
// Sixth Column
@mixin column-6
  grid-column: 11 / 12
// Seventh Column
@mixin column-7
  grid-column: 13 / 14
// Eighth Column
@mixin column-8
  grid-column: 15 / 16
// Ninth Column
@mixin column-9
  grid-column: 17 / 18
// Tenth Column
@mixin column-10
  grid-column: 19 / 20
// Eleventh Column
@mixin column-11
  grid-column: 21 / 22
// Twelth Column
@mixin column-12
  grid-column: 23 / 24

//////////////////////////////////////////////////////////////////////////////
// Mixin: Row Position - Vertical Placement //////////////////////////////////
// Depending on how many items you stack, you will need to add more //////////
//////////////////////////////////////////////////////////////////////////////
@mixin row-1
  grid-row: 1 / 2
@mixin row-2
  grid-row: 3 / 4
@mixin row-3
  grid-row: 5 / 6
@mixin row-4
  grid-row: 7 / 8

  
  
  
  
// 2. THE GRID SETUP  
  
//////////////////////////////////////////////////////////////////////////////
// Default: 12 Column & 1 Row ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
.gridWrapper
  display: grid
  // Initialise 12 Column
  @include colTotal-12
  // Define Row Using Auto - Less Code needed
  grid-template-rows: auto
  // Define Margin Bottom On Items
  > div
    margin-bottom: 1.5em
    @include row-1
    // Cosmetic
    background: salmon
    color: white
    text-align: center
    line-height: 4.5em
  > div:nth-of-type(1)
    @include column-1
  > div:nth-of-type(2)
    @include column-2
  > div:nth-of-type(3)
    @include column-3
  > div:nth-of-type(4)
    @include column-4
  > div:nth-of-type(5)
    @include column-5
  > div:nth-of-type(6)
    @include column-6
  > div:nth-of-type(7)
    @include column-7
  > div:nth-of-type(8)
    @include column-8
  > div:nth-of-type(9)
    @include column-9
  > div:nth-of-type(10)
    @include column-10
  > div:nth-of-type(11)
    @include column-11
  > div:nth-of-type(12)
    @include column-12
 
//////////////////////////////////////////////////////////////////////////////
// Optional - Use a class to overide default. ////////////////////////////////
// See below for recommended responsive approach /////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// <div class="gridWrapper colTotal-X">
  // <div class="box a">1</div>
  // <div class="box b">2</div>
// </div>
//////////////////////////////////////////////////////////////////////////////
.gridWrapper.colTotal-1
  @include colTotal-1
.gridWrapper.colTotal-2
  @include colTotal-2  
.gridWrapper.colTotal-3
  @include colTotal-3  
.gridWrapper.colTotal-4
  @include colTotal-4  
.gridWrapper.colTotal-5
  @include colTotal-5  
.gridWrapper.colTotal-6
  @include colTotal-6    
.gridWrapper.colTotal-7
  @include colTotal-7    
.gridWrapper.colTotal-8
  @include colTotal-8    
.gridWrapper.colTotal-9
  @include colTotal-9    
.gridWrapper.colTotal-10
  @include colTotal-10    
.gridWrapper.colTotal-11
  @include colTotal-11    
.gridWrapper.colTotal-12
  @include colTotal-12    
    




// AUTHOR STYLES FOR LAYOUT 
main.gridWrapper
  z-index: 2000
  position: relative
  grid-template-columns: repeat(2, calc((100% / 2) - 0.75em))

  img
    border: 0.375em solid white
    box-shadow: 0 0 1em 0 rgba(0,0,0,0.1)
      
  article
    
    p
      &:first-of-type
        &:first-letter
          font-family: serif
          font-weight: 500
          font-size: 4em
          float: left
          line-height: 1
          padding-right: 0.17em
      img
        float: right
        margin: 1.5em
        margin-right: 0
    
              
            
!

JS

              
                /* Column setup */
$("body").append('<div class="grid"><div class="wrapper"><div class="columnWrap"></div></div></div>');
var str = '';
for(var cnt=0; cnt < 6; cnt++){
    str += '<div class="column"></div>';
}
$(".columnWrap").append(str);
              
            
!
999px

Console