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

            
              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++
            
          
!
            
              @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;
}
            
          
!
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.
Loading ..................

Console