【问题标题】:Slide divs off screen using jQuery + added navigation arrows使用 jQuery + 添加导航箭头将 div 滑出屏幕
【发布时间】:2012-10-12 13:20:07
【问题描述】:

谁能帮忙在此处找到的代码 sn-p 添加导航箭头

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

【问题讨论】:

    标签: jquery animation html carousel slide


    【解决方案1】:

    应该很容易做到:)

    制作一个“导航控件”包装元素:

    var $controller = $('<div class="control-wrapper" />);
    

    添加两个主要元素作为左右移动按钮:

    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
    };
    

    用函数调用替换 cmets 以移动导航(您已经有逻辑将其向左移动;))

    注意:确保将“cursor:pointer”添加到按钮元素 CSS 类中,以便用户可以点击它们。

    【讨论】:

      【解决方案2】:

      如果有人对此感兴趣,可以为类似问题提供更详细的答案,而且效果很好! jQuery animate divs on/off screen sequentially with navigation arrows

      【讨论】:

        猜你喜欢
        • 2011-06-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多