Переход CSS3 не работает в Firefox, Safari и IE

Я играл с эффектом наведения подкачки изображения с переходами 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;
}

Ваше здоровье!


person DraKal    schedule 27.08.2013    source источник
comment
jsfiddle.net/kYZ9Y   -  person DraKal    schedule 27.08.2013


Ответы (3)


Можно сделать с псевдоэлементами.

.logo {
    background: url(http://via.placeholder.com/300?text=Normal) no-repeat;
    width: 300px;
    height: 300px;
    position: relative;
}
.logo:after {
    content: "";
    opacity: 0;
    display:block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: url(http://via.placeholder.com/300?text=Hover) no-repeat;
    -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:after {
    opacity: 1;
}

https://jsfiddle.net/84bvybjs/

person Priit    schedule 27.08.2013
comment
Симпатичное решение. Узнавайте что-то новое каждый день. - person lc.; 27.08.2013

просто измените легкость на легкость, вот так

-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/

для получения дополнительных функций Easings перейдите на 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;
}
person Gildas.Tambo    schedule 27.08.2013

По крайней мере, для Firefox согласно документация, background-image не анимируется.

Вместо этого попробуйте поместить оба изображения одно поверх другого и анимировать свойство opacity:

.logo {
    float: left;
    z-index: 1;
    width: 300px;
    height: 225px;
    background: url(http://pixellab-design.com/img/2.jpg) no-repeat;
    position: absolute;
}

.logotop {
    float: left;
    z-index: 2;
    width: 300px;
    height: 225px;
    background: url(http://pixellab-design.com/img/1.jpg) 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;
}

.logotop:hover {
    opacity: 0;
}

HTML:

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

Скрипт: http://jsfiddle.net/kYZ9Y/2/

person lc.    schedule 27.08.2013
comment
Большое спасибо, это решило мою проблему :) - person DraKal; 28.08.2013