123

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              h1 The 4 Grid Techniques

.perimeter__float
  h2 Floating Grid (Classic)
  p.description This grid uses "floats" to create it's columns. Since floats don't have layout, you need something to force them to encapsulate thier contents. This is commonly fixed by using a "ClearFix" (which ironicaly uses "display: table-cell"). However, I just used "overflow: hidden." This is a classic grid solution. Columns always align to the top of their container, and the column is only as tall as it's content.
  .container
    .col-6-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. Etsy banksy biodiesel ethnic, cardigan chambray lomo four loko single-origin coffee. Wes anderson dreamcatcher chillwave whatever, before they sold out master cleanse polaroid fixie skateboard yr.
    .col-6-12
      .content
        p Mcsweeney's PBR typewriter banksy wes anderson helvetica. Synth sriracha salvia, selvage pour-over 3 wolf moon 8-bit cosby sweater street art swag. Artisan echo park shoreditch, semiotics iphone dreamcatcher farm-to-table pinterest flexitarian cred ennui irony bicycle rights. Narwhal whatever etsy retro, kogi yr salvia fixie pork belly master cleanse wolf ethical PBR VHS.
  .container
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel.
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 
.perimeter__inline-block
  h2 Inline-block Grid
  p.description 
    | This grid uses "inline-blocks" to create it's columns. The columns are set to "display: inline-block" and their parent can use "text-align" to position the inline elements. This technique was mostly used for achieving horizontal navigation without using floats. This works great however, 4px of margin gets added to each inline-block. You need to <a href="https://css-tricks.com/fighting-the-space-between-inline-block-elements/"> correct</a> this by using "margin-right: -4px." Columns align to the bottom of their container, however you can use vertical alignment to position them. It's columns are only as tall as it's content also.
  .col-6-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. Etsy banksy biodiesel ethnic, cardigan chambray lomo four loko single-origin coffee. Wes anderson dreamcatcher chillwave whatever, before they sold out master cleanse polaroid fixie skateboard yr.
    .col-6-12
      .content
        p Mcsweeney's PBR typewriter banksy wes anderson helvetica. Synth sriracha salvia, selvage pour-over 3 wolf moon 8-bit cosby sweater street art swag. Artisan echo park shoreditch, semiotics iphone dreamcatcher farm-to-table pinterest flexitarian cred ennui irony bicycle rights. Narwhal whatever etsy retro, kogi yr salvia fixie pork belly master cleanse wolf ethical PBR VHS.
  .container
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel. 
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 

.perimeter__table-cell
  h2 Table-cell Grid
  p.description This grid uses "table-cell" to create it's columns. The columns are set to "display: table-cell" and their parent is set to "table." Table-cells fill their rows completely, so you don't get potholes in your rows like you do with Floats and Inline-Blocks. This technique works like a charm, but everyone freaks out about using table behavior in CSS. This behavior is so good, that the "clearfix" to correct floating grids is based off of it! The content of a table-cell can be vertically positioned as well by using "vertical-align: [top, middle, bottom]." 
  .container
    .col-6-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. Etsy banksy biodiesel ethnic, cardigan chambray lomo four loko single-origin coffee. Wes anderson dreamcatcher chillwave whatever, before they sold out master cleanse polaroid fixie skateboard yr.
    .col-6-12
      .content
        p Mcsweeney's PBR typewriter banksy wes anderson helvetica. Synth sriracha salvia, selvage pour-over 3 wolf moon 8-bit cosby sweater street art swag. Artisan echo park shoreditch, semiotics iphone dreamcatcher farm-to-table pinterest flexitarian cred ennui irony bicycle rights. Narwhal whatever etsy retro, kogi yr salvia fixie pork belly master cleanse wolf ethical PBR VHS.
  .container
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel. 
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 

.perimeter__flex
  h2 FlexBox Grid
  p.description This grid uses "Flexbox" to create it's columns. The parent element holding the columns is set to "display: flex," and that tells all of it's immediate children to line the fuck UP! Done, columns made. This is the new way to create columns. Flexbox gives you all kinds of settings to control the position, order, alignment, size and behavior of it's contents. Flexbox fucking rocks and should be used all the time. I use Table-Cell as a fall back in browsers that don't support flexbox. I do this because table-cell has the closest behavior to Flexbox and it gives me vertical and horizontal centering.
  .container
    .col-6-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. Etsy banksy biodiesel ethnic, cardigan chambray lomo four loko single-origin coffee. Wes anderson dreamcatcher chillwave whatever, before they sold out master cleanse polaroid fixie skateboard yr.
    .col-6-12
      .content
        p Mcsweeney's PBR typewriter banksy wes anderson helvetica. Synth sriracha salvia, selvage pour-over 3 wolf moon 8-bit cosby sweater street art swag. Artisan echo park shoreditch, semiotics iphone dreamcatcher farm-to-table pinterest flexitarian cred ennui irony bicycle rights. Narwhal whatever etsy retro, kogi yr salvia fixie pork belly master cleanse wolf ethical PBR VHS.
  .container
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel. 
    .col-4-12
      .content
        p Bushwick fanny pack high life wolf single-origin coffee american apparel, cred twee gluten-free mixtape mlkshk ethical carles Austin direct trade. 
        
.perimeter__colophone
  h2 Outtro
  p.description All grids are responsive, yet none use any breakpoints. I wanted to show the vanilla behavior of each technique when resized.
  
            
          
!
            
              *
  box-sizing border-box
  
:root
  font-size 18px
  
body
  background-color #eee
  color #333
  font-family source sans pro
  font-weight 200
  line-height 1.25
  margin-top 2rem
  
h1
  font-size 8vw
  font-weight 900
  padding 1rem
  text-align center
  text-shadow 5px 5px 0 #ccc
  text-transform uppercase
  
h2
  font-size 5vw
  font-weight 600
  position relative
  text-align center
  text-shadow 5px 5px 0 #eee
  text-transform uppercase
  
  &::after
    border-bottom 5px solid #333
    bottom -1rem
    content: ''
    left 50%
    position absolute
    transform translateX(-50%)
    width 6rem
 
 a
   background-color #0fc
   color #333
   text-decoration none
   
   &:hover
     background-color #333
     color #0fc
  
.description
  font-family source serif pro
  line-height 1.5
  padding 2rem 6rem
  
[class^=perimeter]
  background-color white
  box-shadow 10px 10px 0 #ddd
  margin 4rem auto
  padding 2rem
  width 80vmax
  
.content
  background-color #333
  color #ddd
  margin 1rem
  padding 1rem
  
[class^=col]
  background:
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 25%,
      #0fc 0,
      #0fc 50%
    ),
    #333
  background-size: 2rem 2rem
  //height 6rem
  
[class*='6-12']
  width (6/12) * 100%
  
[class*='4-12']
  width (4/12) * 100%
  
.perimeter
  
  &__float
    margin-top 2rem
    
    .container
      overflow hidden
      
    .col-6-12, 
    .col-4-12
      float left
      
  &__inline-block
    
    .container
      text-align center
      
    .col-6-12, 
    .col-4-12
      display inline-block
      margin-right -3px
      //vertical-align top
  
  &__table-cell
    
    .container
      display table
      
    .col-6-12, 
    .col-4-12
      display table-cell
      
  &__flex
    
    .container
      display flex
      
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console