前端基础笔记06-练习:滚动渐变色背景
利用动画特效制作带有滚动渐变色背景效果
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>背景滚动渐变色</title>
<style type="text/css">
div{
width: 200px;
height: 50px;
border-radius: 25px;
/* position: absolute; */
/* 设置背景渐变色 */
background-image: linear-gradient(to right, #fabcaf,#ffff00,#83ff75,#ff00ff,#00ffff,#ff55ff,#acd6fe,#4efeb3,#fabcaf);
/* 将背景的渐变色范围变大,横向尽量拉宽 */
background-size: 1000% 150%;
/* 设置 动画名(自定义) 时间 动画过渡类型(ease平滑过渡) 循环次数(infinite无限循环)*/
animation: bg-color-move 3s ease infinite;
}
/* 帧动画 */
@keyframes bg-color-move{
0%{background-position: 0%,100%;}
25%{background-position: 25%,75%;}
50%{background-position: 50%,50%;}
75%{background-position: 75%,25%;}
100%{background-position: 100%,0%;}
}
p{
display: block;
width: 200px;
height: 50px;
line-height: 50px;
text-align: center;
font-size: 32px;
font-weight: 600;
font-family: "ms reference sans serif";
}
</style>
</head>
<body>
<div>
<p>submit</p>
</div>
</body>
</html>