【发布时间】:2021-02-22 18:33:48
【问题描述】:
我需要鼠标点击和拖动而不是水平滚动条。
当我点击并拖动应该在拖动方向左右移动的子 div 时。
任何带有 css 或 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>
【问题讨论】:
-
你可以使用 mouseDown 和 mouseUp 事件来改变父容器的 X 位置。
-
错字错误,在
border中,solid和overflow中缺少'i' 应该是hidden而不是hihdden
标签: javascript jquery html css