css背景渐变色linear-gradient函数简介与示例demo

1、默认使用

linear-gradient():函数用于创建一个线性渐变的 “图像”。为了创建一个线性渐变,你需要设置一个起始点和一个方向(指定为一个角度)的渐变效果;还要定义终止色。

默认语法:background: linear-gradient(direction, color-stop1, color-stop2, …);
direction:方向或者角度,不设置时默认从上至下渐变;
color-stop1, color-stop2, …:用于指定渐变的起止颜色。

    .iconfont:hover{
      background: linear-gradient(#989eac, #454a5d)
    }
    
    .iconfont:hover{
      background: linear-gradient(#a0a3a5, #f7f8f7);
    }

在这里插入图片描述
在这里插入图片描述

2、改变渐变方向

默认为从上到下渐变,下面的为从左上到右下背景渐变写法

background: linear-gradient(to bottom right, #b1b6c0, #777c8d, #4e5367);

3、改变渐变角度

不设置角度时

background: linear-gradient(red, green, blue);

在这里插入图片描述

45度时

background: linear-gradient(45deg, red, green, blue);

在这里插入图片描述

90度时

background: linear-gradient(90deg, red, green, blue);

在这里插入图片描述

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值