【问题标题】:Jquery animate next div over set widthJquery在设置宽度上为下一个div设置动画
【发布时间】:2012-05-28 11:02:37
【问题描述】:

我问了一个类似的问题,得到了这个答案,但是当我试图将其移至可用标记时,我很幸运。

基本上我有 4 个 div x 3 个 div 的行,当它们被单击时,我需要以下 div 来扩展网格中的所有其他 div 并在需要时切换。我试过使用动画和切换无济于事。此处使用表格的一个示例http://jsfiddle.net/gGc5K/

如果可能,我需要使用 nexr 方法以相同的方式(通过切换关闭)工作以下标记。

谢谢

  <!--div in the grid--><div class="gridBox" id="one"></div>
    <div class="pop" id="bigOne">Content here and a toggle link</div><!--This div needs to expand over the full grid-->

 <!--div in the grid--><div class="gridBox" id="two"></div>
    <div class="pop" id="bigTwo">Content here and a toggle link</div><!--This div needs to expand over the full grid-->

【问题讨论】:

    标签: javascript jquery jquery-animate toggle


    【解决方案1】:
    var top = 0,
        left = 0;
    
    $("td").click(function() {
        var ref = $(this);
        if ($(this).hasClass('currentAnimated')) {
            $(this).css({
                "z-index": 1
            }).animate({
                top: top,
                left: left,
                width: "40px",
                height: "39px"
            }, "4s", function() {
                ref.removeClass('currentAnimated');
            })
        } else {
            top = $(this).position().top;
            left = $(this).position().left;
            $(this).css({
                "z-index": 1
            }).animate({
                top: 0,
                left: 0,
                width: "120px",
                height: "120px"
            }, "4s", function() {
                ref.addClass('currentAnimated')
            });
        }
    });
    

    DEMO

    【讨论】:

    • 干杯我觉得我说得不够清楚,我想要它做的是在上面的代码示例中,有一个网格布局,每个单元格都是一个 div,当你点击div 它将动画并显示在该点之前隐藏的下一个潜水
    猜你喜欢
    • 2013-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多