如何在CSS3中制作一个闪烁的图像

时间:2015-11-12 08:30:15

标签: css3 css-transitions css-animations

我是CSS3的新手,正在处理用于闪烁图像的CSS3代码。我只需要显示一个连续闪烁的图像。我不能使用GIF图像,因为图像是动态的。

1 个答案:

答案 0 :(得分:9)

它非常简单......只需在图像的不透明度上使用CSS3动画

我希望这有帮助..

这是一个工作小提琴http://jsfiddle.net/rameezrami/27754r4f/1/或使用以下html

<html>
<head>
<style>
/* Firefox old*/
@-moz-keyframes blink {
    0% {
        opacity:1;
    }
    50% {
        opacity:0;
    }
    100% {
        opacity:1;
    }
} 

@-webkit-keyframes blink {
    0% {
        opacity:1;
    }
    50% {
        opacity:0;
    }
    100% {
        opacity:1;
    }
}
/* IE */
@-ms-keyframes blink {
    0% {
        opacity:1;
    }
    50% {
        opacity:0;
    }
    100% {
        opacity:1;
    }
} 
/* Opera and prob css3 final iteration */
@keyframes blink {
    0% {
        opacity:1;
    }
    50% {
        opacity:0;
    }
    100% {
        opacity:1;
    }
} 
.blink-image {
    -moz-animation: blink normal 2s infinite ease-in-out; /* Firefox */
    -webkit-animation: blink normal 2s infinite ease-in-out; /* Webkit */
    -ms-animation: blink normal 2s infinite ease-in-out; /* IE */
    animation: blink normal 2s infinite ease-in-out; /* Opera and prob css3 final iteration */
}
</style>
</head>
<body>
<img class="blink-image" src="http://www.chicagoexcelclasses.com/wp-content/uploads/2014/04/css31-180x180.jpg">
</body>
</html>