Pen*_*lse 5 html css css-animations
我在一个简单的图像上使用 CSS 动画。
我希望脉冲动画仅针对图像的一部分。
我如何制作脉冲动画,以便只有文本“Trello”改变不透明度?
这是我的代码:
.element {
/*animation-delay: 2s;*/
animation: pulse 3s infinite;
margin: 0 auto;
display: table;
margin-top: 50px;
animation-direction: alternate;
}
@keyframes pulse {
0% {
opacity: 1;
}
100% {
opacity: 0.3;
}
}
html,
body {
height: 100%;
background-color: #e74c3c;
}Run Code Online (Sandbox Code Playgroud)
<img src="https://d78fikflryjgj.cloudfront.net/images/50b4ebc64391dc394a38e73aed57f0e2/header-logo.png" alt="" class="element" />Run Code Online (Sandbox Code Playgroud)
小智 6
您可以将此示例用于两者。我希望它对你有帮助。
.pulse {
animation: pulse 3s infinite;
margin: 0 auto;
display: table;
margin-top: 50px;
animation-direction: alternate;
-webkit-animation-name: pulse;
animation-name: pulse;
}
@-webkit-keyframes pulse {
0% {
-webkit-transform: scale(1);
}
50% {
-webkit-transform: scale(1.1);
}
100% {
-webkit-transform: scale(1);
}
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
html,
body {
height: 100%;
background-color: #e74c3c;
}Run Code Online (Sandbox Code Playgroud)
<img src="https://d78fikflryjgj.cloudfront.net/images/50b4ebc64391dc394a38e73aed57f0e2/header-logo.png" alt="" class="pulse" />Run Code Online (Sandbox Code Playgroud)