我将创建一个脉冲颜色效应,最大持续时间为一分钟。为了对CSS产生这种效果,我可以做这样的事情:
@-webkit-keyframes pulse {
0% { background-color: #ed8c55; }
50% { background-color: #FFF; }
100% { background-color: #ed8c55; }
}
@-moz-keyframes pulse {
0% { background-color: #ed8c55; }
50% { background-color: #FFF; }
100% { background-color: #ed8c55; }
}
@-o-keyframes pulse {
0% { background-color: #ed8c55; }
50% { background-color: #FFF; }
100% { background-color: #ed8c55; }
}
@keyframes pulse {
0% { background-color: #ed8c55; }
50% { background-color: #FFF; }
100% { background-color: #ed8c55; }
}
.element {
width: 50px;
height: 50px;
background: #ed8c55;
-webkit-animation: pulse 3s infinite; /* Safari 4+ */
-moz-animation: pulse 3s infinite; /* Fx 5+ */
-o-animation: pulse 3s infinite; /* Opera 12+ */
animation: pulse 3s infinite; /* IE 10+, Fx 29+ */
}
<div class="element"></div>
,但是在这个我无法控制时间。特别是,我会在按钮内的图标中产生这种效果
<md-button aria-label="Info" id="info" title="info" ng-click="openInfo()" class="md-icon-button">
<i class="zmdi zmdi-help red-color"></i>
</md-button>
<i />
元素应最大脉冲一分钟红色。这可以使用AngularJS还是简单地使用JavaScript?
但是在这个我无法控制时间
您可以使用animation-iteration-count
。由于动画需要3秒,您可以给它一个20
的值:
.element {
width: 50px;
height: 50px;
background: #ed8c55;
-webkit-animation: pulse 3s 20; /* Safari 4+ */
-moz-animation: pulse 3s 20; /* Fx 5+ */
-o-animation: pulse 3s 20; /* Opera 12+ */
animation: pulse 3s 20; /* IE 10+, Fx 29+ */
}