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

Auto Save

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="slider-mask">
<div id="container" class="AB-slidebar">
    <div class="slider-aft">
      <img src="https://user0514.cdnw.net/shared/img/thumb/SAYA160312500I9A3721_TP_V4.jpg"
        width="800px" height="533px">
    </div>
    <div class="slider-bef">
        <img src="https://user0514.cdnw.net/shared/img/thumb/OOKAWA6_ana20140726104327_TP_V4.jpg"
        width="800px" height="533px">
    </div>
    <div class="handle-wrapper">
        <div class="slider-bar">
            <img src="https://www.flaticon.com/download/icon/59089?icon_id=59089&author=1&team=1&keyword=Arrows+right+and+left+filled+triangles&pack=111235&style=Others&style_id=0&format=png&color=%23000000&colored=1&size=24&selection=1&type=standard&search=right+left+arrow"
            class="slider-handle">
          
</div></div></div></div>
              
            
!

CSS

              
                .slider-mask {
	width:960px;
	height:540px;
	overflow:hidden;
	margin:0 auto;
}
.AB-slidebar {
	position:relative;
    width: 967px;
    height: 540px;
    right: 4px;
    overflow:hidden;
}
.slider-aft, .slider-bef {
    position: absolute;
    top: 0px;
    left: 4px;
    overflow:hidden;
}
.handle-wrapper {
    position:relative;
    width: 8px;
    height: 540px;
    left: 952px;
    z-index:10;
}
.slider-bar {
    width: 1px;
    height: 540px;
    position: absolute;
    left: 4px;
    background-color: white;
    opacity: .7;
}
.slider-handle {
    position: relative;
    top: 255px;
    left: -14px;
    z-index: 100;
}



              
            
!

JS

              
                // Add External Scripts/Pens
//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js
//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js

jQuery(function () {
    var before = $('.slider-bef');
    var after = $('.slider-after');
    var handle = $('.handle-wrapper');
    var slider = $('.AB-slidebar');
	  var tooltip = $('.slider-tip');
    
    var currentWidth = $(before).width(); //get current width of top image
    var newTopWidth = currentWidth * 2/3; //calculate new top width -> 2/3 of current width
    var slideLeft = newTopWidth * 2/3; //set # of pixels to slide left
    var slideRight = newTopWidth; //set # of pixels to slide right
	
    
    before.width(newTopWidth); //set top image with new width
    handle.css('left', newTopWidth); //set left margin for bar

function slideBar(e) {
    
  setTimeout(function () {
     var newWidth = parseInt($(handle).css('left'));
     // set width of before img div 
     before.width(newWidth);
        }, 30);

     e.stopPropagation();
    }


  handle.draggable({
        containment: slider,
        axis: 'x'
    });

  slider.bind('drag', slideBar).bind('mousedown',     function(){
    	tooltip.fadeOut(10);
    });
    

});
              
            
!
999px

Console