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

            
              <div class="wrapper">
<aside>
  <div class="input-con">
    <h3>justify-content</h3>
    <select class="opt justify-content">
      <option>start</option>
      <option>center</option>
      <option>end</option>
      <option>space-between</option>
      <option>space-around</option>
      <option>space-evenly</option>
    </select>
  </div>
  
   <div class="input-con">
    <h3>align-content</h3>
    <select class="opt align-content">
      <option>start</option>
      <option>center</option>
      <option>end</option>
      <option>space-between</option>
      <option>space-around</option>
      <option>space-evenly</option>
    </select>
  </div>
  
  <div class="input-con">
    <h3>justify-items</h3>
    <select class="opt justify-items">
      <option selected>stretch</option>
      <option>start</option>
      <option>center</option>
      <option>end</option>
      <option>baseline</option>
    </select>
  </div>
  
  <div class="input-con">
    <h3>align-items</h3>
    <select class="opt align-items">
       <option selected>stretch</option>
       <option>start</option>
      <option>center</option>
      <option>end</option>
      <option>baseline</option>
    </select>
  </div>
  
  <div class="input-con input-con-multi">
    <h3>justify-self</h3>
    <label for="jself-of">Item No.:</label>
    <input type="text" placeholder="enter grid item no." id="jself-of" class="jself-of in-small"/>
    <label for="jself">Select Value:</label>
     <select id="jself" class="opt jself in-small">
                                                     <option>stretch</option>
      <option>start</option>
      <option>center</option>
      <option>end</option>
      <option>baseline</option>
    </select>
  </div>
                                                <div class="input-con input-con-multi">
    <h3>align-self</h3>
    <label for="aself-of">Item No.:</label>
    <input type="text" placeholder="enter grid item no." id="aself-of" class="aself-of in-small"/>
    <label for="aself">Select Value:</label>
    <select id="aself" class="opt aself in-small" justify-self">
      <option>stretch</option>
      <option>start</option>
      <option>center</option>
      <option>end</option>                           <option>baseline</option>
    </select>
  </div>
                                                                
  <div class="input-con">
              <button class="btn btn-reset">Reset</button>
              </div>
</aside>
  
<main>
  <div class="item">
  </div>
    <div class="item">
  </div>
    <div class="item">
  </div>
    <div class="item">
  </div>
    <div class="item">
  </div>
</main>
</div>
            
          
!

CSS

            
              body {
  background-color: #F5F5F5;
  color: #555;
  font-size: 1.1em;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  margin: 0;
}

html,
body {
  height: 100%;
}
* {
  box-sizing: border-box;
}

.wrapper {
  display: flex;
  flex-flow: row wrap;
  max-height: 100vh;
}

aside {
  flex: 100px;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(34, 51, 68, 0.8);
  padding: 2em 1em;
  overflow: auto;
}

aside h3 {
  padding: .2em 0;
  text-shadow: 0 0.1em 0.1em #333;
  border-bottom: .1em solid currentColor;
  box-shadow: 0 0.1em 0.1em -0.1em #333;
}

aside .input-con {
  margin-bottom: 2em;
}

.input-con .opt {
  display: block;
  width: 100%;
}
 
.input-con .opt,
.input-con .in-small {
  padding: .8em .4em;
  box-shadow: 0 1px 1px rgba(51, 51, 51, 0.14);
  border: 1px solid #333;
}

.opt option {
  background: #234;
  color: white;
}

.input-con-multi * {
  margin: 0.7em 0;
}

.input-con-multi label,
.input-con-multi .in-small,
.input-con-multi .opt{
  display: inline-block;
  width: 40%;
}

.input-con-multi .in-small,
.input-con-multi .opt {
  width: 50%;
}

.btn {
	display: block;
  width: 100%;
  padding: .2em .1em;
  font-size: 1.5em;
  border: 0;
  background: linear-gradient(45deg,tomato, rgb(255, 114, 53));
  color: white;
  outline: 0;
  box-shadow: 0 0.3em 0.3em rgba(51, 51, 51, 0.45);
  cursor: pointer;
  transition: background .3s ease-out;
}

.btn:hover {
  background: tomato;
}

.btn:active {
  transform: translateY(.2em);
   box-shadow: 0 0.1em 0.1em rgba(51, 51, 51, 0.45);
}
.btn:active {
  
}


main {
	position: relative;
  display: grid;
  justify-content: start;
  justify-items: stretch;
  align-items: stretch;
  align-content: start;
  grid-auto-columns: 100px;
  grid-auto-rows: 100px;
  background: #fff4f4;
  padding: 0 2em;
  min-height: 100vh;
  flex: 1 0 60%;
  overflow: hidden;
  box-shadow: inset 1.8em 0 #fff4f4, inset 2em 0 rgba(51, 51, 51, 0.2),
    inset -1.8em 0 #fff4f4, inset -2em 0 rgba(51, 51, 51, 0.2);
}

main::before {
  content: "";
  position: absolute;
  top: 50%;
 left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: .2em;
  background: rgba(51, 51, 51, 0.21);
}

main::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  width: .2em;
  background: rgba(51, 51, 51, 0.2);
}

main .item {
	display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3em;
  padding: 1rem;
  color: white;
  background: #987;
  margin: 0 1rem 1rem 0;
  transition: all .3s ease-out;
}

main .item:nth-child(2),
main .item:nth-child(3),
main .item:nth-child(5){
  margin-right: 0;
}

main .item:nth-child(4),
main .item:nth-child(5){
  margin-bottom: 0;
}




.item:first-child {
  grid-row: 1/span 2;
  grid-column: 1/span 3;
  background: tomato;
  justify-self: stretch;
}

.item:last-child {
  grid-column: 3/span 2;
  background: #299;
}

.item:nth-child(2) {
  grid-row: 1;
  grid-column: 4/span 2;
}

.item:nth-child(3) { 
  grid-column: 4/span 2;
  grid-row: 2;
}

.item:nth-child(4) { 
  grid-column: 1/span 2;
  grid-row: 3/span 2;
}
.item:nth-child(5) { 
  grid-column: 3/span 3;
  grid-row: 3/span 2;
  background: #299;
}



@media screen and (max-width: 800px) {
  body {
    font-size: 70%;
  }
  
  aside {
    flex: 3;
  }
  
  main {
  	grid-auto-columns: 70px;
    grid-auto-rows: 70px;
    flex:1 0 4;
  }

}
            
          
!

JS

            
              var gridCon= document.querySelector("main");

for(var i=0; i<gridCon.children.length; i++) {
  var item= gridCon.children[i];
  item.textContent= i+1;
}

var jCon= document.querySelector(".justify-content");

var aCon= document.querySelector(".align-content");

var jItems= document.querySelector(".justify-items");

var aItems= document.querySelector(".align-items");

jCon.addEventListener("change", updatejCon, false);
aCon.addEventListener("change", updateaCon, false);
jItems.addEventListener("change", updatejItems, false);
aItems.addEventListener("change", updateaItems, false);

function updatejCon() {
  gridCon.style.justifyContent= this.value;
}

function updateaCon() {
  gridCon.style.alignContent= this.value;
}

function updatejItems() {
  gridCon.style.justifyItems= this.value;
}

function updateaItems() {
  gridCon.style.alignItems= this.value;
}

var jselfOf= document.querySelector(".jself-of"),
aselfOf= document.querySelector(".aself-of"),
jself= document.querySelector(".jself"),
aself= document.querySelector(".aself"),
gItem, gItem2;

jselfOf.addEventListener("input", updatejselfOf, false);
aselfOf.addEventListener("input", updateaselfOf, false);
jself.addEventListener("change", updatejself, false);
aself.addEventListener("change", updateaself, false);

function updatejselfOf() {
  gItem= this.value;
}
function updateaselfOf() {
  gItem2= this.value;
}
function updatejself() {
  gridCon.children[gItem-1].style.justifySelf= this.value;
}
function updateaself() {
   gridCon.children[gItem2-1].style.alignSelf= this.value;
}


var btnReset=  document.querySelector(".btn-reset");
btnReset.addEventListener("click", function() {
  jCon.value= "start";
  aCon.value= "start";
  jItems.value= "stretch";
  aItems.value= "stretch";
  jself.value= "stretch";
  aself.value= "stretch";
  jselfOf.value= 0;
  aselfOf.value= 0;
  
   gridCon.style.justifyContent= jCon.value;
 gridCon.style.alignContent= aCon.value;
 gridCon.style.justifyItems= jItems.value;
gridCon.style.alignItems= aItems.value;
   gridCon.style.justifySelf= jSelf.value;
gridCon.style.alignSelf= aSelf.value;
});
            
          
!
999px

Console