我有一个在页面加载时发生的动画。我想在悬停时为相同的元素设置动画。但是,然后我再次关闭鼠标,再次播放原始过渡。如何将鼠标关闭时的不透明度保持在 100%,这样中间的闪光就不会发生?
http://jsfiddle.net/edlea/qN2T4/
HTML
<div class="bubble animated"></div>
CSS
.bubble{
background-color:#000;
width:50px;
height:50px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
/* INITIAL ANIMATION ON PAGE LOAD */
-webkit-animation-name: bounceIn;
-moz-animation-name: bounceIn;
-o-animation-name: bounceIn;
animation-name: bounceIn;
}
/* THIS IS WHAT I WANT ON HOVER */
.bubble:hover{
-webkit-animation-name: blob;
-moz-animation-name: blob;
-o-animation-name: blob;
animation-name: blob;
-webkit-animation-duration:0.5s;
-moz-animation-duration:0.5s;
-ms-animation-duration:0.5s;
-o-animation-duration:0.5s;
animation-duration:0.5s;
-webkit-animation-timing-function: ease;
-moz-animation-timing-function: ease;
-ms-animation-timing-function: ease;
-o-animation-timing-function: ease;
animation-timing-function: ease;
cursor:pointer;
}
/* * * * * * * * * * * * * * */
/* Animations */
/* * * * * * * * * * * * * * */
.animated{
-webkit-animation-fill-mode:both;
-moz-animation-fill-mode:both;
-ms-animation-fill-mode:both;
-o-animation-fill-mode:both;
animation-fill-mode:both;
-webkit-animation-duration:0.5s;
-moz-animation-duration:0.5s;
-ms-animation-duration:0.5s;
-o-animation-duration:0.5s;
animation-duration:0.5s;
}
/* * * * * * * blob * * * * * * */
@-webkit-keyframes blob {
0% {
-webkit-transform: scale(1);
}
100% {
-webkit-transform: scale(1.2);
}
}
@-moz-keyframes blob {
0% {
-moz-transform: scale(1);
}
100% {
-moz-transform: scale(1.2);
}
}
@-o-keyframes blob {
0% {
-o-transform: scale(1);
}
100% {
-o-transform: scale(1.2);
}
}
@keyframes blob {
0% {
transform: scale(1);
}
100% {
transform: scale(1.2);
}
}
/* * * * * * * bounceIn * * * * * * */
@-webkit-keyframes bounceIn {
0% {
opacity: 0;
-webkit-transform: scale(.1);
}
30% {
-webkit-transform: scale(1.15);
}
60% {
opacity: 1;
-webkit-transform: scale(.9);
}
100% {
opacity: 1;
-webkit-transform: scale(1);
}
}
@-moz-keyframes bounceIn {
0% {
opacity: 0;
-moz-transform: scale(.1);
}
30% {
-moz-transform: scale(1.15);
}
60% {
opacity: 1;
-moz-transform: scale(.9);
}
100% {
opacity: 1;
-moz-transform: scale(1);
}
}
@-o-keyframes bounceIn {
0% {
opacity: 0;
-o-transform: scale(.1);
}
30% {
-o-webkit-transform: scale(1.15);
}
60% {
opacity: 1;
-o-webkit-transform: scale(.9);
}
100% {
opacity: 1;
-o-webkit-transform: scale(1);
}
}
@keyframes bounceIn {
0% {
opacity: 0;
transform: scale(.1);
}
30% {
transform: scale(1.15);
}
60% {
opacity: 1;
transform: scale(.9);
}
100% {
opacity: 1;
transform: scale(1);
}
}