我在YouTube上关注一个教程,关于如何创建一个Glowing Border Animation with CSS
我试着自己实施,并取得了相当的成功,然而,我遇到了一个我无法解决的问题.当我观看我的动画时,有一个不均匀的过渡.看起来就像是两个图像粘在一起, colored颜色 过渡被切断了.
我如何才能在过渡看起来很顺利的情况下解决那里的问题?
我创建了一个JSFdle来显示我的意思:
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #151320;
}
.box {
position: relative;
width: 300px;
height: 300px;
color: #fff;
font: 300 2rem 'Montserrat';
text-align: center;
text-transform: uppercase;
display: flex;
align-items: center;
}
.box::before,
.box::after {
content: '';
z-index: -1;
position: absolute;
width: calc(100% + 30px);
height: calc(100% + 30px);
top: -15px;
left: -15px;
background: linear-gradient(45deg, #0096FF, #0047AB, #000000, #6082B6, #87CEEB, #00008B, #145DA0, #00008B, #145DA0, #0096FF, #0047AB, #000000, #6082B6, #87CEEB);
background-repeat: repeat;
border-radius: 5px;
background-size: 600%;
animation: border 12s linear infinite;
}
.box::after {
filter: blur(25px);
}
@keyframes border {
0% {
background-position: 0% 0%;
}
100% {
background-position: 250% 250%;
}
}
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<div class="box">
Greetings fellow developer!
</div>
注意:动画一开始看起来很流畅,但在大约70秒后,你会遇到过渡不对准的"截断".