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.

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

              
                <div id="wrapper">
  
  <div class="center">
  
    <h1>RoboSquidTV - Flexbox</h1>

<div id="controls">
  <h1>Flex-Direction</h1>
<form class="flex-direction radioGroup" onClick="updateDirection()">
  <div>
    <input type="radio" id="radioRow" name="flexdirection" value="row" checked="checked"/> <label for="radioRow">Row</label> 
  </div>
   <div>
    <input type="radio" id="radioRowR" name="flexdirection" value="row-reverse"/> <label for="radioRowR">-Reverse</label> 
  </div>
     <div>
    <input type="radio" id="radioCol" name="flexdirection" value="column"/> <label for="radioCol">Column</label> 
  </div>
     <div>
    <input type="radio" id="radioColR" name="flexdirection" value="column-reverse"/> <label for="radioColR">-Reverse</label> 
  </div>
 </form>
   <h1>Justify-Content</h1>
  <form class="justify-content radioGroup" onClick="updateJustify()">
  <div>
    <input type="radio" id="radioStart" name="justifyContent" value="flex-start" checked="checked"/> <label for="radioStart">Flex-Start</label> 
  </div>
   <div>
    <input type="radio" id="radioCenter" name="justifyContent" value="center"/> <label for="radioCenter">Center</label> 
  </div>
     <div>
    <input type="radio" id="radioEnd" name="justifyContent" value="flex-end"/> <label for="radioEnd">Flex-End</label> 
  </div>
     <div>
    <input type="radio" id="radioBetween" name="justifyContent" value="space-between"/> <label for="radioBetween">Space-Between</label>
  </div>
    <div>
           <input type="radio" id="radioAround" name="justifyContent" value="space-around"/> <label for="radioAround">Space-Around</label> </div>
 </form>
  
  <h1>Align-Items</h1>
  <form class="justify-content radioGroup" onClick="updateAlign()">
  <div>
    <input type="radio" id="radioStartA" name="alignItems" value="flex-start" checked="checked"/> <label for="radioStartA">Flex-Start</label> 
  </div>
   <div>
    <input type="radio" id="radioCenterA" name="alignItems" value="center"/> <label for="radioCenterA">Center</label> 
  </div>
     <div>
    <input type="radio" id="radioEndA" name="alignItems" value="flex-end"/> <label for="radioEndA">Flex-End</label> 
  </div>
     <div>
    <input type="radio" id="radioStretch" name="alignItems" value="stretch"/> <label for="radioStretch">Stretch</label>
  </div>
    <div>
           <input type="radio" id="radioBaseline" name="alignItems" value="baseline"/> <label for="radioBaseline">Baseline</label> </div>
 </form>
  
  
</div>

<div id="exampleContainer">

<div class="example" id="example1">Box 1</div>
<div class="example" id="example2">Box 2</div>
<div class="example" id="example3">Box 3</div>

</div>
<p>This Pen is part of a <a href="https://youtu.be/Mkza0N8NiK4">CSS tutorial available on Youtube </a> </p>
  <ul class="social">
    <li><a href="https://www.youtube.com/channel/UC7vYUkA-s5XVjS7UoyGSFbg"> Youtube </a></li>
    <li><a href="https://www.facebook.com/robosquidtv/"> Facebook </a></li>
    <li><a href="https://twitter.com/RoboSquidTV"> Twitter </a></li>
  </ul>
  
  </div>
  

  
</div>
              
            
!

CSS

              
                *, *:before, *:after {
  box-sizing: inherit;
}

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

body, html {
  display: flex;
  flex: 1;
  height: 100%;
  width: 100%;
  flex-direction: column;
  box-sizing: border-box;
  transition: all 3s ease;
}

body{
  font-size: 16px;
  font-family: 'Roboto', sans-serif;
background: #43C6AC;  /* fallback for old browsers */
background: linear-gradient(to right, #191654, #43C6AC); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
color: #FFF;
}

#wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;

}

#controls {
  padding: 2em;
  background-color: #66BB6A;
  font-weight: bold;
  border-radius: 0.4em;
  padding: 2em;
  margin: 1em;
}

#controls h1 {
  font-size: 1.2em;
  
}

#controls input[type="radio"] {
display: none;
}

.radioGroup {
  border: solid 0.1em rgba(255,255,255, 0.2);
  border-radius: 4em;
  display: flex;
  justify-content: space-between;
  
}

.radioGroup label {
  display: flex;
  align-items: center;
  padding: 0.5em;
  flex: 1;
  min-height: 2em;
  border-radius: 4em;
}


.radioGroup input[type="radio"]:checked + label{
  background-color: rgba(0,0,0,0.2);
}

.radioGroup input[type="radio"]:not + label{
  background-color: none;
}

#exampleContainer {
  margin: 1em;
  display: flex;
  flex-direction: row;
  width: 55em;
  border: 5px solid #FFF;
  min-height: 20em;
  align-items: flex-start;
}

.example{
  justify-content: center;
  font-weight: bold;
  color: #FFF;
  border-color: #FFF;
  border-style: solid;
  border-width: 0px;
  min-height: 4em;
  min-width: 8em;
  display: flex;
  align-items: center;
  
}

#example1 {
    background-color: #2ecc71;
}
#example2 {
  background-color: tomato;
}
#example3 {
  background-color: turquoise ;
}


span{
  display: inline-block;
  width: 6em;
  margin: 0.1em;
}

a  {

  color: #FFF;
}

.center {
  display: flex;
  flex-direction: column;
  text-align: center;
  align-items: center;
  justify-content: center;

}
              
            
!

JS

              
                var flex = document.querySelector('#exampleContainer');


function updateDirection() {
  let selected = document.querySelector('input[name="flexdirection"]:checked').value;
  flex.style.flexDirection = selected;
}


function updateJustify() {
  let selected = document.querySelector('input[name="justifyContent"]:checked').value;
  flex.style.justifyContent = selected;
}

function updateAlign() {
  let selected = document.querySelector('input[name="alignItems"]:checked').value;
  flex.style.alignItems = selected;
}
              
            
!
999px

Console