前端工作中常用Css(渐变)

渐变
一、线性渐变(向上/向下/向左/向右/对角线)
background-image: linear-gradient( 方向/角度 , 颜色1,颜色2,颜色3....);

注: 方向: 在关键字 to 后面加上 top、bottom、right、left 中的某一个关键字或多个关键字。
例:

background-image: linear-gradient(to right bottom , #FF0000,#FFF200, #1E9600);

左上到右下渐变

重复线性渐变:repeating-linear-gradient()

background-image: repeating-linear-gradient(45deg, #210f60 10px, #fff 30px, #333 10px);

重复线性渐变

二、径向渐变(由其中心定义)
background-image: radial-gradient(shape size at position, start-color, ..., last-color);

shape 为椭圆形,size 为最远角,position 为中心。
shape 参数定义形状。它可接受 circle 或 ellipse 值。默认值为 ellipse(椭圆)
size 参数定义渐变的大小。它可接受四个值:
closest-side :从中心点向外扩展渐变,到离中心点最近的一边结束。
farthest-side :以离渐变中心点最远的那一边计算圆的半径
closest-corner :以离渐变中心点最近的元素顶角计算渐变的范围。
farthest-corner :以离渐变中心点最远的顶角计算圆的半径。

background-image: radial-gradient(circle at 50% 50%, red, yellow, green);

径向渐变
平铺的径向渐变:repeating-radial-gradient

background-image: repeating-radial-gradient(circle at 20% 40%,#eea2a2 20px, #57c6e1 20px, #b49fda 40px, #7ac5d8 40px, #b49fda 80px);

平铺的径向渐变

常见使用:
  1. 边框渐变:
.border-grident {
  margin-top: 20px;
  width: 200px;
  height: 100px;
  border: 4px solid;
  border-image: linear-gradient(to right, #8f41e9, #578aef) 4;
}

边框渐变

  1. 文字渐变:
font-size: 20px;
background-image: linear-gradient(180deg, #fffcbf 0%, #ffb438 100%);
background-clip: text;
-webkit-background-clip: text;
color: transparent;

字体渐变

最后

本文介绍了几种CSS常用的渐变方式,希望对你有所帮助!!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值