首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >IMage在DT处于活动状态时动画较大不处于活动状态时动画较小

IMage在DT处于活动状态时动画较大不处于活动状态时动画较小
EN

Stack Overflow用户
提问于 2011-08-02 08:22:48
回答 1查看 111关注 0票数 0

希望调整此脚本:http://css-tricks.com/examples/InfoGrid/

我已经在每个"dt“中添加了一个图像,我希望它在关闭时是一个特定的大小,然后在选择"dt”时放大动画(很像文本)。当然,当选择了不同的"dt“时,返回到它的原始大小。

也希望对处于“正常状态”与“选定状态”的事物进行更多的控制。有什么想法吗?

代码语言:javascript
运行
复制
<div id="page-wrap">
    <div class="info-col">
        <h2>Superman</h2>
        <a class="image superman" href="http://jprart.deviantart.com/art/Batman-and-Superman-64545242">View Image</a>
    <dl>
          <dt><img src="http://s3.buysellads.com/1252508/65529-1308680363.jpg"> Other text</dt>
          <dd>Stuff Here1</dd>

          <dt><img src="http://s3.buysellads.com/1252508/65529-1308680363.jpg"> Other text 2</dt>
          <dd>Stuff Here2</dd>
</div>

            <div class="info-col">
        <h2>Superman 2</h2>
        <a class="image superman" href="http://jprart.deviantart.com/art/Batman-and-Superman-64545242">View Image 2</a>
    <dl>
          <dt><img src="http://s3.buysellads.com/1252508/65529-1308680363.jpg"> Other text 3</dt>
          <dd>Stuff Here3</dd>

          <dt><img src="http://s3.buysellads.com/1252508/65529-1308680363.jpg"> Other text 4</dt>
          <dd>Stuff Here4</dd>
</div>

</div>

JS:

代码语言:javascript
运行
复制
$(function() {

// Set up variables
var $el, $parentWrap, $otherWrap, $imgBig,
    $allTitles = $("dt").css({
        padding: 5, // setting the padding here prevents a weird situation, where it would start animating at 0 padding instead of 5
        "cursor": "pointer" // make it seem clickable
    }),
    $allCells = $("dd").css({
        position: "relative",
        top: -1,
        left: 0,
        display: "none" // info cells are just kicked off the page with CSS (for accessibility)
    });





// clicking image of inactive column just opens column, doesn't go to link   
$("#page-wrap").delegate("a.image","click", function(e) { 

    if ( !$(this).parent().hasClass("curCol") ) {         
        e.preventDefault(); 
        $(this).next().find('dt:first').click(); 
    } 


});

// clicking on titles does stuff
$("#page-wrap").delegate("dt", "click", function() {

    // cache this, as always, is good form
    $el = $(this);

    // if this is already the active cell, don't do anything
    if (!$el.hasClass("current")) {

        $parentWrap = $el.parent().parent();
        $otherWraps = $(".info-col").not($parentWrap);

        // remove current cell from selection of all cells
        $allTitles = $("dt").not(this);

        // close all info cells
        $allCells.slideUp();


        // return all titles (except current one) to normal size
        $allTitles.animate({
            fontSize: "14px",
            paddingTop: 5,
            paddingRight: 5,
            paddingBottom: 5,
            paddingLeft: 5
        });

        // animate current title to larger size            
        $el.animate({
            "font-size": "18px",
            paddingTop: 10,
            paddingRight: 15,
            paddingBottom: 0,
            paddingLeft: 10
        }).next().slideDown();

        // make the current column the large size
        $parentWrap.animate({
            width: 351
        }).addClass("curCol");

        // make other columns the small size
        $otherWraps.animate({
            width: 140
        }).removeClass("curCol");

        // make sure the correct column is current
        $allTitles.removeClass("current");
        $el.addClass("current");  

    }

});


$("#starter").trigger("click");

});

EN

Stack Overflow用户

回答已采纳

发布于 2011-08-09 00:10:04

对我有效的答案是:

代码语言:javascript
运行
复制
       $el.find('img').animate({         //enlarge image(s)
     width: 225
    }).parent().next().slideDown();


    $allTitles.find('img').animate({         //reduce image(s)
     width: 125
    }).parent().next().slideDown();
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6905998

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档