【发布时间】:2018-05-03 00:33:00
【问题描述】:
寻找在大型全景图像(例如时间轴)上水平滚动的解决方案。
我目前可以使用滚动/双指触摸板进行滚动,但我希望能够使用鼠标单击进行滚动。
我使用 StackOverflow 中的元素绘制了一个 JSFiddle,但我无法让它工作。
HTML:
<div class="outer">
<div class="buttons">
<button id="left">LEFT</button>
<button id="right">RIGHT</button>
</div>
<div class="inner">
<img src="https://via.placeholder.com/550x300">
</div>
</div>
JS:
$('#right').click(function() {
event.preventDefault();
$('#inner').animate({
scrollLeft: "+=200px"
}, "slow");
});
$('#left').click(function() {
event.preventDefault();
$('#inner').animate({
scrollLeft: "-=200px"
}, "slow");
});
CSS:
.buttons {
position: fixed;
left: 0px;
top: 0px;
}
.outer {
width: 200px;
overflow: scroll;
}
.inner {
width: 550px;
top: 25px;
overflow-y: hidden;
overflow-x: scroll;
}
任何帮助将不胜感激。
【问题讨论】:
标签: jquery scroll horizontal-scrolling