我正在尝试通过单击切换按钮平滑地使内联 div 水平滚动,但我不知道如何使这项工作:jsfiddle
这是我的代码:
<button class="go">go</button>
<div class="right">right scroll</div>
<div class="left">left scroll</div>
jQuery
$(function () {
$('.go').on('click', function(){
$('.left').animate({'left': '-105%'});
$('.right').animate({'left': '0px'});
$(this).toggleClass('return go');
$('.return').bind('click', function(){
$('.left').animate({'left': '0px'});
$('.right').animate({'left': '105%'});
$(this).toggleClass('return go');
});
});
});
css
.left {
min-width:100%;
min-height:300px;
background:red;
position:relative;
float:left;
clear:right;
left:0;
}
.right {
min-width:100%;
min-height:300px;
background:blue;
position:relative;
right:-105%;
float:left;
clear:right;
}