【发布时间】:2019-10-22 11:14:15
【问题描述】:
我正在尝试使用 svg 过滤器来获得漂亮的动画和效果。这是我刚刚发现的一个新世界,但我面临一个问题。
我试图重现这种效果:https://www.youtube.com/watch?v=GcSU4xH6_Ro
我不知道如何重现失真的圆圈。
我知道我可以使用过滤器和 svg,但实际上如果我将我的 svg 过滤器应用于框所有 div 都会受到影响,而不是这个圆圈。
我想知道是否可以让 svg 像“镜头”一样 如果你想看代码,我做了一个 jsFiddle:https://jsfiddle.net/wekhz7rb/
我想只用 CSS 来做这个
<div class="box">
<svg class="svg" xmlns="http://www.w3.org/2000/svg" id="effect"
width="275px" height="275px">
<filter id="noise">
<feTurbulence baseFrequency="0.05" numOctaves="2" result="noise">
</feTurbulence>
<feComposite operator="in" in2="SourceGraphic"></feComposite>
<feDisplacementMap in="SourceGraphic" in2="noise" scale="50">
</feDisplacementMap>
</filter>
<!-- <circle cx="137" cy="137" r="137" fill="red" filter="url(#noise)">
</circle> -->
</svg>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
<div class="text">DREAMS</div>
</div>
@import url(//fonts.googleapis.com/css?family=Archivo+Black);
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: #7427FF;
height: 100vh;
width: 100vw;
}
.box {
height: 550px;
width: 550px;
position: relative;
overflow: hidden;
text-align: center;
filter: url(#noise);
// mask: url(#effect);
}
.svg {
position: absolute;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
z-index: 10;
}
.text {
font-family: 'Archivo Black', sans-serif;
display: inline-block;
font-size: 116px;
line-height: 90px;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 0;
background: linear-gradient(0deg, rgba(117,62,255,1) 0%,
rgba(249,37,166,1) 40%, rgba(246,154,180,1) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation-name: translate;
animation-timing-function: linear;
animation-duration: 10s;
animation-iteration-count: infinite;
animation-fill-mode: backwards;
@for $i from 1 through 16 {
&:nth-child(#{$i}) {
animation-delay: #{$i * 1}s
}
}
}
@keyframes translate {
from {
transform: translateY(-90px) translateZ(0)
}
to {
transform: translateY(555px) translateZ(0)
}
}
【问题讨论】: