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 = "wrap">
    <div id="content">
        <img src="http://sevensprings.dothome.co.kr/img/3.jpg" />
    </div> 
    <div id ="scrollBar">
        <div id="bar"></div>
    </div> 
</div>
              
            
!

CSS

              
                #wrap{
    width:330px;
    height:600px;
    margin:50px auto;
    overflow:hidden;
}
#content{
    position:relative;
    height:600px;
    width:300px;
    float:left;
}
#scrollBar{
    width:30px;
    height:600px;
    margin-left:300px;
    background-color:#c8c8c8;
}
#bar{
    width:30px;
    height:30px;
    background:#000;
}
              
            
!

JS

              
                $(function(){ 
  
  $("#bar").draggable({axis:'y',containment:'parent'});
  $("#bar").on("drag",function(event, ui){
    getPos()
  });

  var min = 0;           //  컨텐츠 기본 top 값
  var max = -400;        //  컨텐츠 최대(소) top 값 ( -400 을 초과하면 여백이 올라온다. )

  function getPos(){
    var barTop = $("#bar").css("top");              // 스크롤바의 top값 변수저장
    barTop = parseInt(barTop);                      // 실수를 정수로 변환
    var pos = ( barTop*( max - min ))/570 + min;    // 스크롤값 - 컨텐츠 top값으로 변환 
    $("#content").css("top",pos);
  }
  
});  
              
            
!
999px

Console