Oli*_*i C 2 css animation border pulse
我开始在这里创建一个具有我想要的效果的代码笔:https : //codepen.io/oli_js/pen/KKPGZLm?editors=1100
然而,这个脉冲效果从中心点向外辐射,但我希望内圈是透明的,并且效果只是从边界辐射出来。
有谁知道有什么神奇的 CSS 魔法可以做到这一点?!
.pulse {
border-radius: 50px;
height: 80px;
left: 50%;
letter-spacing: 0.05em;
line-height: 50px;
position: absolute;
text-align: center;
text-transform: uppercase;
top: 50%;
width: 80px;
}
.pulse:after {
-webkit-animation: pulse 2s infinite linear;
background: red;
border-radius: 50px;
content: '';
height: 100%;
left: 0;
opacity: 0;
position: absolute;
top: 0;
width: 100%;
}
.button {
background: transparent;
border-radius: 100% 100%;
width: 40px;
height: 40px;
left: 50%;
border:2px solid red;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
@-webkit-keyframes pulse{
0% {transform:scale(0.5);
opacity:0;}
33% {transform:scale(0.8);
opacity:1;}
100% {transform:scale(1);
opacity:0;}
}Run Code Online (Sandbox Code Playgroud)
<div class="pulse">
<div class="button"> </div>
</div>Run Code Online (Sandbox Code Playgroud)
你也可以像这样用阴影效果来做..
.ripple{
display: block;
width: 30px;
height: 30px;
border-radius: 50%;
border:2px red solid;
animation: pulse 2s infinite;
}
@-webkit-keyframes pulse {
0% {
-webkit-box-shadow: 0 0 0 0 rgba(255,0,0, 0.4);
}
70% {
-webkit-box-shadow: 0 0 0 10px rgba(255,0,0, 0);
}
100% {
-webkit-box-shadow: 0 0 0 0 rgba(255,0,0, 0);
}
}Run Code Online (Sandbox Code Playgroud)
<div class="ripple"></div>Run Code Online (Sandbox Code Playgroud)