Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

              
                <div class="wrapper">
  <div class="menu">a</div>
  <div class="nav">b</div>
  <div class="c1"></div>
  <div class="c2"></div>
  <div class="c3"></div>
  <div class="c4"></div>
  <div class="c5"></div>
  <div class="c6"></div>
  <div class="c7"></div>
  <div class="c8"></div>
  <div class="c9"></div>
  <div class="c10"></div>
  <div class="c11"></div>
  <div class="c12"></div>
  <div class="sidebar">d
    <div class="handle"></div>
  </div>
</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.wrapper > div {
  border: 2px solid rgb(233, 171, 88);
  border-radius: 4px;
  background-color: rgba(233, 171, 88, 0.5);
  text-align: center;
  color: #d9480f;
}

.wrapper {
  display: grid;
  grid-template-columns: 304px repeat(12, auto) 64px;
  grid-template-rows: 64px 100vh;
  /* 	grid-template-areas:
	"menu menu menu menu menu menu menu menu menu menu menu menu menu menu"
	"nav c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 sidebar"; */
  column-gap: 40px;
  row-gap: 10px;
}

.menu {
  grid-area: 1/1/1/15;
}

.handle {
  position: relative;
  height: 100%;
  width: 2px;
  background: red;
  justify-self: start;
}

              
            
!

JS

              
                
// Animation
// Duration
const speedSm = 0.01; // 100ms
const speedMdEnter = 0.25; // 250ms
const speedMdExit = 0.2; // 200ms
const speedLgEnter = 0.3; // 300ms
const speedLgExit = 0.25; // 250ms

// Standard curve (On screen)
CustomEase.create("GSAPStandard", "0.4, 0.0, 0.2, 1");

// Deceleration (Enter screen)
CustomEase.create("GSAPDeceleration", "0.0, 0.0, 0.2, 1");

// Acceleration (Leave screen)
CustomEase.create("GSAPAcceleration", "0.4, 0.0, 1, 1");

TweenLite.defaultEase = CustomEase.create("GSAPStandard", "0.4, 0.0, 0.2, 1");

// Selector
let select = function(s) {
    return document.querySelector(s);
  },
  selectAll = function(s) {
    return document.querySelectorAll(s);
  },
  menu = select(".menu"),
  sidebar = select(".sidebar"),
  handle = select(".handle"),
    wrapper = select(".wrapper");


let left = document.createElement("div");


var width = sidebar.offsetWidth;


// Resizable
let leftLastX = 0;
Draggable.create(left, {
  type:"x",
  // bounds:{width: 400},
  trigger: handle,
  cursor: "w-resize",
  onRelease: function() {
      TweenMax.to(sidebar, 0.25, { backgroundColor: "rgba(233, 171, 88, 0.5)", borderColor: "rgb(233, 171, 88)" });
  },
  onDrag: updateLeft,
  onPress: function() {
    leftLastX = this.x;
    TweenLite.to(sidebar, 0.25, { backgroundColor: "#ddd", borderColor: "#888" });
  }
});

function updateLeft() {
  let diffX = this.x - leftLastX;
  leftLastX = this.x;
  
  width = clamp(width - diffX, 64, 400);
  wrapper.style["grid-template-columns"] = "304px repeat(12, auto) " + width + "px";
}

function clamp(value, min, max) {
  return Math.max(min, Math.min(value, max));
}
              
            
!
999px

Console