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.

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.

              <div class="ba-slider">
  <img src="http://egegorgulu.com/assets/img/beforeafter/after.jpg" alt="">       
  <div class="resize">
    <img src="http://egegorgulu.com/assets/img/beforeafter/before.jpg" alt="">
  <span class="handle"></span>
              @import "lesshat";

.ba-slider {
    position: relative;
    overflow: hidden;
.ba-slider img {
    width: 100%;
.resize {
    position: absolute;
    left: 0;
    height: 100%;
    width: 50%;
    overflow: hidden;

.handle { /* Thin line seperator */
  background: rgba(0,0,0,.5);
  cursor: ew-resize;
.handle:after {  /* Big orange knob  */
    position: absolute;
    top: 50%;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    background: #ffb800; /* @orange */
    border:1px solid #e6a600; /* darken(@orange, 5%) */
    border-radius: 50%;
    transition:all 0.3s ease;
      0 2px 6px rgba(0,0,0,.3), 
      inset 0 2px 0 rgba(255,255,255,.5),
      inset 0 60px 50px -30px #ffd466; /* lighten(@orange, 20%)*/ 

.draggable:after {
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
              // Call & init
    var cur = $(this);
    // Adjust the slider
    var width = cur.width()+'px';
    cur.find('.resize img').css('width', width);
    // Bind dragging events
    drags(cur.find('.handle'), cur.find('.resize'), cur);

// Update sliders on resize. 
// Because we all do this: i.imgur.com/YkbaV.gif
    var cur = $(this);
    var width = cur.width()+'px';
    cur.find('.resize img').css('width', width);

function drags(dragElement, resizeElement, container) {
  // Initialize the dragging event on mousedown.
  dragElement.on('mousedown touchstart', function(e) {
    // Check if it's a mouse or touch event and pass along the correct value
    var startX = (e.pageX) ? e.pageX : e.originalEvent.touches[0].pageX;
    // Get the initial position
    var dragWidth = dragElement.outerWidth(),
        posX = dragElement.offset().left + dragWidth - startX,
        containerOffset = container.offset().left,
        containerWidth = container.outerWidth();
    // Set limits
    minLeft = containerOffset + 10;
    maxLeft = containerOffset + containerWidth - dragWidth - 10;
    // Calculate the dragging distance on mousemove.
    dragElement.parents().on("mousemove touchmove", function(e) {
      // Check if it's a mouse or touch event and pass along the correct value
      var moveX = (e.pageX) ? e.pageX : e.originalEvent.touches[0].pageX;
      leftValue = moveX + posX - dragWidth;
      // Prevent going off limits
      if ( leftValue < minLeft) {
        leftValue = minLeft;
      } else if (leftValue > maxLeft) {
        leftValue = maxLeft;
      // Translate the handle's left value to masked divs width.
      widthValue = (leftValue + dragWidth/2 - containerOffset)*100/containerWidth+'%';
      // Set the new values for the slider and the handle. 
      // Bind mouseup events to stop dragging.
      $('.draggable').css('left', widthValue).on('mouseup touchend touchcancel', function () {
      $('.resizable').css('width', widthValue);
    }).on('mouseup touchend touchcancel', function(){
  }).on('mouseup touchend touchcancel', function(e){

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