css如何实现网页背景动态渐变效果


本文摘自PHP中文网,作者V,侵删。

HTML部分:

1

2

3

4

5

6

7

8

9

10

11

12

13

<!DOCTYPE html>

<html>

<head>

  <meta charset="UTF-8">

  <title> 渐变――天际线</title>

  <link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

   <div>

      渐变――天际线

    </div>

</body>

</html>

实现背景颜色渐变不需要在HTML(结构)部分做任何操作 这里加了一行字,方便显示效果;

(推荐教程:CSS教程)

CSS部分:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

body{

  margin: 0;

  padding: 0;

  font-family: "montserrat";

  background-image: linear-gradient(125deg,#E4FFCD,#6DD5FA,#2980B9,#E4FFCD);  background-size: 400%;

  animation: bganimation 15s infinite;

}

 

.text{

  color: white;

  text-align: center;

  text-transform: uppercase;

  margin: 400px 0;

  font-size: 22px;

}

 

@keyframes bganimation {

  0%{

    background-position: 0% 50%;

  }

  50%{

    background-position: 100% 50%;

  }

  100%{

    background-position: 0% 50%;

  }

}

效果如图:

阅读剩余部分

相关阅读 >>

vue组件中如何引入css文件

@charset规则怎么用

css如何修改字体大小

css中如何调整图片位置

css有哪些布局方式

css设置背景图大小该怎么做

myeclipse css 不起作用怎么办

css不区分大小写吗?

html设置背景图片的代码是什么

css如何实现开关效果

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...