如何在background-size属性上应用转换

时间:2013-12-21 09:15:35

标签: jquery css css3 transition

我尝试在背景大小上进行转换,怎么做?

http://jsfiddle.net/FT4CQ/17/

    <div class="cell" style="width: 345.53px; height: 210.53px; background-image: url(https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-prn1/1521894_10151755196011682_1359230168_n.jpg); position: absolute;-webkit-transition: top 0.5s, left 0.5s; transition: top 0.5s, left 0.5s;" data-delay="2" data-height="200" data-width="331" data-state="move" id="2-2"></div>

    .cell:hover{
        transition: background-size 1s;
        -webkit-transition:  background-size 1s; 
        background-size:cover;
        cursor: pointer;
}

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

使用background-position: cover;

看起来效果不佳

试试这个:

<div class="cell"></div>

.cell {
    -moz-transition: background-size 2s ease-in;
    /* WebKit */
    -webkit-transition: background-size 2s ease-in;
    /* Opera */
    -o-transition: background-size 2s ease-in;
    /* Standard */
    transition: background-size 2s ease-in;
    width: 345.53px; 
    height: 210.53px; 
    background-image: url(https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-prn1/1521894_10151755196011682_1359230168_n.jpg);
    position: absolute;
    background-size: 150% 150%;
}

.cell:hover{ 
    background-size: 100% 100%;
    cursor: pointer;
}

Updated fiddle