[TOC]
>[success] # 动态渐变颜色背景
有时候会有 **动态渐变背景色** 的 **样式需求** ,实现代码如下:
demo.html
~~~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>动态渐变颜色背景</title>
<style>
.box{
height: 300px;
width: 300px;
background: linear-gradient(-45deg, #2d8cf0, #19be6b, #ff9900, #ed3f14);
animation: gradientBG 15s ease infinite;
background-size: 400% 400%;
}
@keyframes gradientBG{
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
~~~