jQuery切换动画仅在Safari中失败

时间:2015-11-10 21:17:40

标签: javascript jquery css safari

JS:

$('.greenBox').hover(function(){
    $(this).addClass('expanded');
    $(this).removeClass('contracted');
}, function(){
    $(this).removeClass('expanded');
    $(this).addClass('contracted');
});

CSS:

.expanded {
    height: auto;
    min-height:200px;
    max-height:750px;
    margin-top:5px;
    // to make the box move up add back the bottom 300px
    // bottom: 300px;
    background: linear-gradient(#812990, #9e248e);
    -webkit-transition-timing-function: linear; 
    transition-timing-function: linear; 
}

以下是“contracted”类。

.contracted {
    max-height: 137px;
    overflow:hidden;
}

1 个答案:

答案 0 :(得分:2)

jQuery正在运行。 Safari中的背景颜色没有变化,因为您需要使用:

background: -webkit-linear-gradient(#812990, #9E248E);

http://jsfiddle.net/hsqgqojx/