Mouse click and Drag Instead of Horizontal Scroll bar( To view full content of child Div)

前端 未结 1 1381
逝去的感伤
逝去的感伤 2021-02-07 11:42

I need Mouse click and Drag instead of Horizontal scroll bar.

\"Reference When i click and drag th

相关标签:
1条回答
  • 2021-02-07 12:41

    You can use .draggable() function from jquery UI. Here's a link to sample i created based on your code. Updated Code http://jsfiddle.net/3mh2b7rk/4/

    jQuery("#child").draggable({ 
        cursor: "move", 
        containment: "parent",
        stop: function() {
          if(jQuery("#child").position().left < 1)
              jQuery("#child").css("left", "720px");
        }
    });
    .parent{width:300px; border:5px solid red; overflow:hidden; left:20px}
    .child-container{width:1730px;left:-710px;position:relative;}
    #child{ width:1000px; float:left; font-size:15px; font-family:arial; padding:10px 5px 10px 0;left:720px; border-right:4px solid red}
    .clear {clear:both;}
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
    <div class="parent">
      <div class="child-container">
        <div id="child"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum </div>
        <div class="clear"></div>
      </div>
    </div>

    0 讨论(0)
提交回复
热议问题