3

我正在一个网站上工作,每行有 2 个 div,每个 45%。我想设置它,以便如果您连续悬停在一个 DIV 上,该行中的另一个 DIV 将随着悬停的 DIV 展开而缩小,然后在悬停离开时恢复。缩小的 DIV 可能在行中悬停的 DIV 之前或之后,这就是我被卡住的地方。

HTML 将如下所示,一遍又一遍地重复:

<div class="row">
    <div class="cell upcoming">
        <img src="stills/press/press-logo-gdc2013.jpg" class="general"><p class="one">Panelist - Game Developers Conference 2013</p>
        <p class="two">[Panel Name TBD]</p>
        <p class="three"><b>Panel Date/Location:</b> [TBD] on March 25-29, 2013 at GDC (San Francisco, California)</p>
        <p class="three"><b>Panelists:</b> [TBD]</p>
        <p class="three"><b>Panel Blurb:</b> [TBD]</p>
    </div>

    <div class="cell upcoming">
        <img src="stills/press/press-logo-wizard-world-st-louis.jpg" class="general"><p class="one">Panelist - Wizard World St. Louis 2013</p>
        <p class="two">[Panel Name TBD]</p>
        <p class="three"><b>Panel Date/Location:</b> [TBD] on March 22-24, 2013 at Wizard World (St. Louis, Missouri)</p>
        <p class="three"><b>Panelists:</b> [TBD]</p>
        <p class="three"><b>Panel Blurb:</b> [TBD]</p>
    </div>
</div>

“行”没有 CSS,但“单元格”的 CSS 是

div.cell { position:relative; margin:2px; float:left; width:45%; text-align:justify; vertical-align:top; border:2px solid; padding:10px; border-radius:25px; -moz-border-radius:25px; }

部分JQUERY是这样的:

 $('.cell')
    .on('mouseenter', function(){
        $(this).animate ({width:"75%"},"slow);
    })
    .on('mouseleave', function(){
        $(this).animate ({width:"45%"},"slow);
    });

当然,我希望“行”中的另一个“单元格”(无论是左边还是右边)随着另一个的增长而缩小,但我不知道如何确定该行中“其他 DIV”的标识符" 或者让两件东西同时制作动画。

帮助表示赞赏!

4

2 回答 2

1

您可以siblings()在这种情况下使用来获取其他.cell元素。

$('.cell')
    .on('mouseenter', function(){
        $(this).animate ({width:"75%"},"slow").siblings('.cell').animate({'width': '15%'}, "slow");
    })
    .on('mouseleave', function(){
        $(this).add($(this).siblings('.cell')).animate ({width:"45%"},"slow");
    });
于 2013-02-05T18:26:18.950 回答
0

这是手风琴效果:http ://components.developers4web.com/accordion-effect#TSAccordionHead695732

你也可以玩这个:http ://www.w3schools.com/jquery/eff_fadeout.asp

于 2013-02-05T18:36:15.370 回答