1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > CSS 实现炫酷的动态背景效果

CSS 实现炫酷的动态背景效果

时间:2018-10-10 01:02:43

相关推荐

CSS 实现炫酷的动态背景效果

活不多说,直接开始

效果图:

HTML:

一个万能的div

<div class="bgc"></div>

主要是css部分

使用background属性

纯色线性渐变(linear-gradient)径向渐变(radial-gradient)角向渐变(conic-gradient)多重线性渐变(repeating-linear-gradient)多重径向渐变(repeating-radial-gradient)多重角向渐变(repeating-conic-gradient)

实现以上效果需要使用repeating-conic-gradient多重角向渐变

.bgc {background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.8deg);width: 500px;height: 300px;}

这里的角度小于1deg时,效果最佳

为了更加炫酷,为其加上动画

@keyframes change {0% {}20% {background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.7deg);}40% {background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.6deg);}60% {background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.5deg);}80% {background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.4deg);}100% {background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.4deg);}}

.bgc {background: repeating-conic-gradient(rgb(255, 255, 255), rgb(109, 241, 76), rgb(255, 255, 255) 0.8deg);width: 500px;height: 300px;animation: change 2s linear infinite;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。