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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

            
              h1 Flex-like grids

p.header Ever wanted to set flexbox to space-(something) and got awful last row layouts, ? Here's an alternative approach using CSS Grid

p.instruction Resize the frame width to check the how elements grows, shrinks and wraps

h2 Growing / Shrinking  width elements
p Using auto-fit minmax();

- var elements = 11;

- var n = 1;
.grid
  while n <= elements
    div
      h1= n++

h2 Fixed width elements, space-around style
p Using auto-fit minmax() and justify-items: center

- var n = 1;
.grid.fix-grid--around
  while n <= elements
    div.fix-el
      h1= n++

h2 Fixed width elements, space-between style
p Using auto-fit and justify-content:space-between

- var n = 1;
.grid.fix-grid--between
  while n <= elements
    div.fix-el
      h1= n++

h2 Flexbox issue demo
p With growing / shrinking elements and space-between

- var n = 1;
.flex
  while n <= elements
    div
      h1= n++
      
h2 Flexbox issue demo
p With fixed width elements and space-between

- var n = 1;
.flex.space-bt
  while n <= elements
    div
      h1= n++
            
          
!

CSS

            
              @import url('https://fonts.googleapis.com/css?family=Roboto');

/*SASS variable that determine the "min-width" of the elements*/
$bp: 140px;

.grid{
  /*sets the container as a grid with variable number of columns*/
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax($bp,1fr));
  grid-gap:1em;
  margin:1em 0 3em;
}


/* modifiers for the grid with fixed width elements, space-around style example*/
.fix-grid--around{
  justify-items: center;
}
/* modifiers for the grid with fixed width elements, space-between style example*/
.fix-grid--between{
  grid-template-columns: repeat(auto-fit, $bp);
  justify-content: space-between;
}

.grid div{
  height: $bp;
  /*just centering the numbers*/
  display:flex;
  align-items:center; 
  justify-content:center;
}

.fix-el{
  width: $bp;
}

/*random color generator, from @joshuajcollinsworth 's awesome pen, so credit where it's due :) https://codepen.io/joshuajcollinsworth/pen/aEJGvg*/
@for $i from 1 through 11 {
	$red: random(255);
	$green: random(255);
	$blue: random(255);
	.grid div:nth-child(#{$i}), .flex div:nth-child(#{$i}){
		background: rgb($red, $green, $blue);
  }
}

/*for the flexbox demonstration*/
.flex{
  margin-top: 1em;
  display:flex;
  flex-flow: row wrap;
  justify-content:space-between;
}

.flex div{
  flex: 1 1 $bp;
  height: $bp;
  display:flex; 
  justify-content:center;
  align-items:center;
  margin:1em;
}

/* for flexbox fixed width demonstration*/
.space-bt div{
  flex: 0 0 $bp;
}

/* aesthetic thingies*/
body{
  font-family: 'Roboto', sans-serif;
  color:#333;
  background: #FFF0E0;
}

body>h1{/*clickbait :p */
  color:#F00;
  font-size:4rem;
}

body>h1, body>h2, {
  margin:1rem 1rem 0 1rem; 
}
body>p{
  margin:0.5rem 1rem;
}

.header{
  font-size:1.5em;
}

.instruction{
  font-size:1.3em;
  color:steelblue;
}
            
          
!

JS

            
              
            
          
!
999px

Console