Đây là mã mà bạn muốn. Nó được chứng minh là hoạt động trên IE, Safari, Chrome, Firefox, v.v.
Đây là phần HTML.
<div id="slide-wrap" style="width:1000px; height:200px; overflow:hidden; padding:0 auto;">
<div id="inner-wrap" style="float:left;">
<!-- 'Put Inline contains here like below.' -->
<div class='containBox' style="width:250px; height:100%; float:left; display:inline-block;"></div>
<!-- ... -->
<div class='containBox' style="width:250px; height:100%; float:left; display:inline-block;"></div>
<!-- 'Put Inline contains here like above.' -->
</div>
<div style="display: block; width:40px; height:60px; position: absolute; margin-left:0px; margin-top:40px">
<img id='scroll_L_Arrow' src='../assets/img/l-arrow.png' onclick="scrollThumb('Go_L')"/>
</div>
<div style="display: block; width:40px; height:60px; position: absolute; margin-left:960px; margin-top:40px">
<img id='scroll_R_Arrow' src='../assets/img/r-arrow.png' onclick="scrollThumb('Go_R')"/>
</div>
</div>
Đây là phần jQuery trong hàm JavaScript.
function scrollThumb(direction) {
if (direction=='Go_L') {
$('#slide-wrap').animate({
scrollLeft: "-=" + 250 + "px"
}, function(){
// createCookie('scrollPos', $('#slide-wrap').scrollLeft());
});
}else
if (direction=='Go_R') {
$('#slide-wrap').animate({
scrollLeft: "+=" + 250 + "px"
}, function(){
// createCookie('scrollPos', $('#slide-wrap').scrollLeft());
});
}
}
Để ẩn các mũi tên, vui lòng xem tại đây. Detect end of horizontal scrolling div with jQuery
Chúc mừng bạn đời đã làm việc :) – GSTAR
@GSTAR Tìm kiếm điều tương tự. Làm thế nào bạn có được tất cả các hình ảnh của bạn để ở trong một hàng ngang? Tôi bọc cho dòng tiếp theo. – Rob
'trắng-không gian: nowrap' – Si8