background: linear-gradient(direction,color-stop1,color-stop2,...);
direction
:用角度值指定渐变的方向(或角度)。color-stop1,color-stop2,...
:用于指定渐变的起止颜色。注意:至少需要两种颜色。
background: linear-gradient(to left,#d3959b,#bfe6ba);
background: linear-gradient(to right,#d3959b,#bfe6ba);
background: linear-gradient(to top,#d3959b,#bfe6ba);
background: linear-gradient(to bottom,#d3959b,#bfe6ba);
background: linear-gradient(to top right,#d3959b,#bfe6ba);
to right top = to top right
:从左下角到 右上角,对角线角度
background: linear-gradient(45deg,#d3959b,#bfe6ba);
和 to top right
有细微差别(背景为正方形的时候无差别)。
background: linear-gradient(45deg,#d3959b 20%,#bfe6ba);
background: linear-gradient(to right,#feac5e,#c779d0,#4bc0c8);
background: linear-gradient(45deg,#feac5e,#c779d0,#4bc0c8);
background: linear-gradient(45deg,rgba(254,172,94,0.5),rgba(199,121,208,0.5),rgba(75,192,200,0.5));