CSS3 过渡在 Firefox、Safari 和 IE 中不起作用

标签 css css-transitions browser-support

我正在玩带有 CSS3 过渡的图像交换悬停效果。不幸的是,它只适用于 Chrome。我已经看到很多来自 CSS3 转换的示例,它们在 Chrome、Firefox 和 Safari 中完美运行,但这次不是……:( 问题出在哪里?

http://jsfiddle.net/kYZ9Y/

.logo {
float: left;
z-index: 1;
width: 325px;
height: 73px;
background: url(../img/logo.png) no-repeat;
position: absolute;
-moz-transition: all .4s ease;
-webkit-transition: all .4s ease;
-ms-transition: all .4s ease;
-o-transition: all .4s ease;
transition: all .4s ease;
}

.logo:hover {
z-index: 2;
opacity: 1;
background: url(../img/logo1.png) no-repeat;
}

干杯!

最佳答案

像这样把ease改成ease-in-out

-moz-transition: all .4s ease-in-out;
    -webkit-transition: all .4s ease-in-out;
    -ms-transition: all .4s ease-in-out;
    -o-transition: all .4s ease-in-out;
    transition: all .4s ease-in-out;

演示:http://jsfiddle.net/kYZ9Y/4/

有关更多缓动函数,请访问 http://easings.net/

标记:

<div class="logo"></div>

风格:

.logo {
    float: left;
    z-index: 1;
    width: 300px;
    height: 225px;
    background: url(http://pixellab-design.com/img/1.jpg) no-repeat;
    position: absolute;
    -moz-transition: all .4s ease-in-out;
    -webkit-transition: all .4s ease-in-out;
    -ms-transition: all .4s ease-in-out;
    -o-transition: all .4s ease-in-out;
    transition: all .4s ease-in-out;
}

.logo:hover {
    z-index: 2;
    opacity: 1;
    background: url(http://pixellab-design.com/img/2.jpg) no-repeat;
}

关于CSS3 过渡在 Firefox、Safari 和 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18455485/

相关文章:

javascript - 将 CSS 类与 jQuery/Javascript 合并

jQuery 选项卡 - 长选项卡名称,小浏览器窗口 - 如何仍然显示在一行上?

html - 一行中的 div 标签

javascript - 具有 CSS 动画和过渡效果的 Vue.js Todo 任务

javascript - Coverflow 类似 jQuery 的效果

javascript - 哪些浏览器不支持缓存清除?

javascript - 浏览器支持 window.location.reload(true)

html - 如何防止 img 在 div 中调整大小

javascript - 禁用过渡动画

ios - caniuse.com 上的 Safari 和 iOS Safari 有什么区别?