svg动画(适合边框、图形动画)
@keyframes svgdh {
0%{
stroke-width: 1;
stroke-dasharray: 0 650;
}
60% {
stroke-width: 5;
stroke-dasharray : 350 650
}
100% {
stroke-width: 1;
stroke-dasharray : 650 650
}
}
.svgDH{
animation: svgdh 2s ease-out infinite;
}
<svg
xmlns="http://www.w3.org/2000/svg"
height="400"
width="200"
version="1.1"
>
<polyline
points="0,1 120,1 120,382 0,382"
style="fill: none; stroke: #777777; stroke-width: 1"
/>
<polyline
points="0,1 120,1 120,382 0,382"
class="svgDH"
style="fill: none; stroke: #e93718; stroke-width: 1"
/>
filter属性制作动画:
<style>
/* 驰骋之心 */
.filter-mix {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
height: 200px;
filter: contrast(20);
background: #fff;
}
.filter-mix::before {
content: "";
position: absolute;
width: 120px;
height: 120px;
border-radius: 50%;
background: #333;
top: 40px;
left: 40px;
z-index: 2;
filter: blur(6px);
box-sizing: border-box;
animation: filterBallMove 4s ease-out infinite;
}
.filter-mix::after {
content: "";
position: absolute;
width: 80px;
height: 80px;
border-radius: 50%;
background: #3F51B5;
top: 60px;
right: 40px;
z-index: 2;
filter: blur(6px);
animation: filterBallMove2 4s ease-out infinite;
}
@keyframes filterBallMove {
50% {
left: 140px;
}
}
@keyframes filterBallMove2 {
50% {
right: 140px;
}
}
/* soul test */
.container {
width: 500px;
height: 200px;
position: relative;
padding: 2em;
filter: contrast(20);
background-color: black;
overflow: hidden;
}
span {
color: white;
font-size: 4rem;
text-transform: uppercase;
line-height: 1;
animation: letterspacing 5s infinite alternate ease-in-out;
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translate3d(-50%, -50%, 0);
letter-spacing: -2.2rem;
}
@keyframes letterspacing {
0% {
letter-spacing: -2.2rem;
filter: blur(.3rem);
}
50% {
filter: blur(.5rem);
}
100% {
letter-spacing: .5rem;
filter: blur(0rem);
color: #fff;
}
}
</style>
<body>
<div class="filter-mix"></div>
<div class="container">
<span>
soul
body
</span>
</div>
</body>