CSS 容器背景 10 种颜色渐变Demo(linear-gradient())

语法

background: linear-gradient(direction,color-stop1,color-stop2,...);

direction:用角度值指定渐变的方向(或角度)。
color-stop1,color-stop2,...:用于指定渐变的起止颜色。

注意:至少需要两种颜色。

第一个

background: linear-gradient(to left,#d3959b,#bfe6ba);

to left 设置渐变 从右到左,相当于 270deg

8c68569ad0450fb972c98a286e50a409

第二个

background: linear-gradient(to right,#d3959b,#bfe6ba);

to right 设置渐变 从左到右,相当于 90deg

439acbc1b20396f360ff35386b290c60

第三个

background: linear-gradient(to top,#d3959b,#bfe6ba);

to top 设置渐变 从下到上,相当于 0deg

fbe790fd2adaef451e1ef180d2ec1024

第四个

background: linear-gradient(to bottom,#d3959b,#bfe6ba);

85c22a511e3848e0d45aaf7b5951d103

第五个

background: linear-gradient(to top right,#d3959b,#bfe6ba);

to right top = to top right :从左下角到 右上角,对角线角度

fd3efa609df750c53c590ea86a28fc2a

第六个

background: linear-gradient(45deg,#d3959b,#bfe6ba);

to top right 有细微差别(背景为正方形的时候无差别)。

b268691a5a86a7421b216f20a29f787e

第七种

background: linear-gradient(45deg,#d3959b 20%,#bfe6ba);

用百分比指定起始颜色的位置,默认值为 0%

01fee2f2e452abb29b7d009a06de21e5

第八种

background: linear-gradient(to right,#feac5e,#c779d0,#4bc0c8);

af29ed304da38edb3d6656927ebbdf99
3884e6186595441b2207e6924d1c58d1

第九种

background: linear-gradient(45deg,#feac5e,#c779d0,#4bc0c8);

73d64d03da3451314bd00c8786061ec9

第十种

background: linear-gradient(45deg,rgba(254,172,94,0.5),rgba(199,121,208,0.5),rgba(75,192,200,0.5));

96c493ce6afb107f6efe34187f8daa45

rgba 使用了 0.5 的透明度。

48dbfe6757ed50dc57376f2005bb91a7

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容