单击并拖动鼠标,而不是水平滚动条(要查看子Div的全部内容) [英] Mouse click and Drag Instead of Horizontal Scroll bar( To view full content of child Div)

查看:30
本文介绍了单击并拖动鼠标,而不是水平滚动条(要查看子Div的全部内容)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要单击鼠标并拖动,而不是水平滚动条.

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

当我单击并拖动应沿拖动方向左右移动的子div时.

任何使用CSS或jquery/JS的解决方案

Any solution with css or jquery/JS

我的代码:

.parent{
  width:300px;
  border:5px sold red;
  overflow:hihdden; 
  float:left;
}
.child{
  width:1000px;
  float:left;
  font-size:15px;
  font-family:arial;
  padding:10px;
}

<div class="parent">
    <div class="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>

推荐答案

您可以在jquery用户界面中使用 .draggable()函数.这是我根据您的代码创建的示例的链接.更新的代码 http://jsfiddle.net/3mh2b7rk/4/

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>

这篇关于单击并拖动鼠标,而不是水平滚动条(要查看子Div的全部内容)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆