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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <body class="layout-column">  

  <div class="radio-controls layout-align-center-center layout-row">
    
    <div class="radio-group">    
      <div class="radio-title">Horizontal Alignment</div>      
      <div class="radio-item">
        <input type="radio" name="horizontal" id="h-start" value="start" />
        <label for="h-start">Start</label>
      </div>      
      <div class="radio-item">
        <input type="radio" name="horizontal" id="h-center" value="center" checked />
        <label for="h-center">Center</label>
      </div>      
      <div class="radio-item">
        <input type="radio" name="horizontal" id="h-end" value="end" />
        <label for="h-end">End</label>
      </div>      
    </div>
    
    <div class="radio-group">    
      <div class="radio-title">Vertical Alignment</div>      
      <div class="radio-item">
        <input type="radio" name="vertical" id="v-start" value="start" />
        <label for="v-start">Start</label>
      </div>      
      <div class="radio-item">
        <input type="radio" name="vertical" id="v-center" value="center" checked />
        <label for="v-center">Center</label>
      </div>      
      <div class="radio-item">
        <input type="radio" name="vertical" id="v-end" value="end" />
        <label for="v-end">End</label>
      </div>      
    </div>    
  </div> 
  
  <section class="main layout-align-center-center layout-column flex">  
    <div class="container layout-align-center-center layout-row">
      <div class="box"></div>
    </div>    
  </section>
  
</body>

              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  position: relative;
  font-family: Roboto, "Helvetica Neue", sans-serif;
}

body {
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #eaeaea; 
}

.main {
  padding: 25px 75px 75px;
}

.container {
  position: relative;
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 2px;
  box-shadow: 
    0 2px 2px rgba(0,0,0,0.24), 
    0 0 2px rgba(0,0,0,0.12);
}

.box {
  width: 30%;
  height: 30%;
  background: #673ab7; 
  box-shadow: 
    0 3px 5px -1px rgba(0,0,0,0.2), 
    0 6px 10px 0 rgba(0,0,0,0.14), 
    0 1px 18px 0 rgba(0,0,0,0.12);
}

.radio-controls {
  padding-top: 25px;
}

.radio-group {
  margin: 15px;
}

.radio-title {
  font-size: 20px;
  font-weight: bold;
}

.radio-item {
  font-size: 18px;
  padding: 6px 6px 0 6px;
}

.layout-align,
.layout-align-start-stretch {
  align-content: stretch;
  align-items: stretch;
}

.layout-align,
.layout-align-start,
.layout-align-start-center,
.layout-align-start-end,
.layout-align-start-start,
.layout-align-start-stretch {
  justify-content: flex-start;
}

.layout-align-center,
.layout-align-center-center,
.layout-align-center-end,
.layout-align-center-start,
.layout-align-center-stretch {
  justify-content: center;
}

.layout-align-end,
.layout-align-end-center,
.layout-align-end-end,
.layout-align-end-start,
.layout-align-end-stretch {
  justify-content: flex-end;
}

.layout-align-space-around,
.layout-align-space-around-center,
.layout-align-space-around-end,
.layout-align-space-around-start,
.layout-align-space-around-stretch {
  justify-content: space-around;
}

.layout-align-space-between,
.layout-align-space-between-center,
.layout-align-space-between-end,
.layout-align-space-between-start,
.layout-align-space-between-stretch {
  justify-content: space-between;
}

.layout-align-center-start,
.layout-align-end-start,
.layout-align-space-around-start,
.layout-align-space-between-start,
.layout-align-start-start {
  align-items: flex-start;
  align-content: flex-start;
}

.layout-align-center-center,
.layout-align-end-center,
.layout-align-space-around-center,
.layout-align-space-between-center,
.layout-align-start-center {
  align-items: center;
  align-content: center;
  max-width: 100%;
}

.layout-align-center-center > *,
.layout-align-end-center > *,
.layout-align-space-around-center > *,
.layout-align-space-between-center > *,
.layout-align-start-center>* {
  max-width: 100%;
  box-sizing: border-box;
}

.layout-align-center-end,
.layout-align-end-end,
.layout-align-space-around-end,
.layout-align-space-between-end,
.layout-align-start-end {
  align-items: flex-end;
  align-content: flex-end;
}

.layout-align-center-stretch,
.layout-align-end-stretch,
.layout-align-space-around-stretch,
.layout-align-space-between-stretch,
.layout-align-start-stretch {
  align-items: stretch;
  align-content: stretch;
}

.flex {
  flex: 1;
}

.flex-grow {
  flex: 1 1 100%;
}

.flex-initial {
  flex: 0 1 auto;
}

.flex-auto {
  flex: 1 1 auto;
}

.flex-none {
  flex: 0 0 auto;
}

.flex-noshrink {
  flex: 1 0 auto;
}

.flex-nogrow {
  flex: 0 1 auto;
}

.layout-row > .flex {
  min-width: 0;
}

.layout-column > .flex {
  min-height: 0;
}

.layout,
.layout-column,
.layout-row {
  display: flex;
}

.layout-column {
  flex-direction: column;
}

.layout-row {
  flex-direction: row;
}

.layout-wrap {
  flex-wrap: wrap;
}

.layout-nowrap {
  flex-wrap: nowrap;
}

.layout-fill {
  margin: 0;
  width: 100%;
  min-height: 100%;
  height: 100%;
}

              
            
!

JS

              
                console.clear();

var boxNode = $(".box")[0];
var radios = $("[type=radio]");
var container = $(".container");

var hAlignment = "center";
var vAlignment = "center";

var currentLayout = "layout-align-center-center";

// Initialize transforms on node
TweenLite.set(boxNode, { x: "+=0" });

var box = {
  node: boxNode,
  x: boxNode.offsetLeft,
  y: boxNode.offsetTop,
  transform: boxNode._gsTransform
};

radios.change(setAlignment);

$(window).resize(layout);

function setAlignment() {
    
  if (this.name === "horizontal") {
    hAlignment = this.value;
  } else {
    vAlignment = this.value;
  }
  
  container.removeClass(currentLayout);
  currentLayout = "layout-align-" + hAlignment + "-" + vAlignment;
  container.addClass(currentLayout);
    
  layout();
}

function layout(event) {
   
  // Last offset position
  var lastX = box.x;
  var lastY = box.y;

  // Record new offset position
  box.x = box.node.offsetLeft;
  box.y = box.node.offsetTop;

  // Exit if box hasn't moved
  if (lastX === box.x && lastY === box.y) return;
  
  // Reversed delta values taking into account current
  // transforms in case animation was interrupted
  var x = box.transform.x + lastX - box.x;
  var y = box.transform.y + lastY - box.y;  

  var duration = event && event.type === "resize" ? 0 : 0.5;
  
  // Tween to 0,0 to remove the transforms
  TweenLite.fromTo(box.node, duration, { x: x, y: y }, { x: 0, y: 0, ease: Power1.easeInOut }); 
}
              
            
!
999px

Console