任何人都可以帮助您将导航箭头添加到此处的代码段
Slide a div offscreen using jQuery 并给出第一个答案.... http://jsfiddle.net/jtbowden/ykbgT/2/
我希望能够添加方向箭头或上一个/下一个链接
以下代码
HTML:
<div id="container">
<div id="box1" class="box">Div #1</div>
<div id="box2" class="box">Div #2</div>
<div id="box3" class="box">Div #3</div>
<div id="box4" class="box">Div #4</div>
<div id="box5" class="box">Div #5</div>
</div>
的CSS:
body {
padding: 0px;
}
#container {
position: absolute;
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
}
.box {
position: absolute;
width: 50%;
height: 300px;
line-height: 300px;
font-size: 50px;
text-align: center;
border: 2px solid black;
left: 150%;
top: 100px;
margin-left: -25%;
}
#box1 {
background-color: green;
left: 50%;
}
#box2 {
background-color: yellow;
}
#box3 {
background-color: red;
}
#box4 {
background-color: orange;
}
#box5 {
background-color: blue;
}
的javascript:
$('.box').click(function() {
$(this).animate({
left: '-50%'
}, 500, function() {
$(this).css('left', '150%');
$(this).appendTo('#container');
});
$(this).next().animate({
left: '50%'
}, 500);
});
它的工作非常出色,但导航是一个方向,点击方框
即可激活提前致谢
AOR
答案 0 :(得分:0)
应该很容易做到:)
制作一个“导航控件”包装元素:
var $controller = $('<div class="control-wrapper" />);
添加2个主要元素作为左右移动按钮:
var $left = $('<span class="move left" />').appendTo($controller),
$right = = $('<span class="move right"/>').appendTo($controller);
为每个动画的每个移动元素添加一个事件处理程序:
$left.click(function(event) {
////MOVE THE NAV LEFT
};
$right.click(function(event) {
////MOVE THE NAV RIGHT
};
用函数调用替换注释以移动导航(你已经有逻辑将其向左移动;)
注意:确保将“光标:指针”添加到按钮元素CSS类中,以便它们看起来可以被用户点击。
答案 1 :(得分:0)
如果有兴趣的话,这里有一个类似问题的更详细的答案,可以完美地运作! jQuery animate divs on/off screen sequentially with navigation arrows