赞
踩
SS3 渐变(gradients)可以在两个或多个指定的颜色之间显示平稳的过渡。CSS3 定义了两种类型的渐变(gradients):
1、线性渐变(Linear Gradients)- 向下/向上/向左/向右/对角方向;
2、径向渐变(Radial Gradients)- 由它们的中心定义。
线性渐变
(1)从上到下渐变(默认情况)
background: linear-gradient(red, blue);
(2)从左到右渐变
background: linear-gradient(to right, red , blue);
(3)对角方向渐变
background: linear-gradient(to bottom right, red , blue);
(4)指定角度渐变
background: linear-gradient(120deg, red, blue);
(5)从上到下,带有多个颜色结点渐变
background: linear-gradient(red, green, blue);
(6)带有彩虹颜色和文本渐变
background: linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet);
(7)从左至右,带有透明度
background: linear-gradient(to right, rgba(255,0,0,0), rgba(255,0,0,1));
(8)重复线性渐变
background: repeating-linear-gradient(red, yellow 10%, green 20%);
2.径向渐变
(1)颜色结点均匀分布
background: radial-gradient(red, green, blue);
(2)颜色结点不均匀分布
background: radial-gradient(red 5%, green 15%, blue 60%);
(3)形状为圆形渐变
background: radial-gradient(circle, red, yellow, green);
(4)重复径向渐变
background: repeating-radial-gradient(red, yellow 10%, green 15%);
<view class='container'>
<view class='demo view11'>11</view>
<view class='demo view12'>12</view>
<view class='demo view13'>13</view>
<view class='demo view14'>14</view>
<view class='demo view15'>15</view>
<view class='demo view16'>16</view>
<view class='demo view17'>17</view>
<view class='demo view18'>18</view>
<view class='demo view19'>19</view>
<view class='demo view20'>20</view>
<view class='demo view21'>21</view>
<view class='demo view22'>22</view>
<view class='demo view23'>23</view>
</view>
.view11 {
background: linear-gradient(red, blue);
}
.view11 {
background: linear-gradient(red, blue);
}
.view13 {
background: linear-gradient(to bottom right, red , blue);
}
.view14 {
background: linear-gradient(120deg, red, blue);
}
.view15 {
background: linear-gradient(red, green, blue);
}
.view16 {
background: linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet);
}
.view17 {
background: linear-gradient(to right, rgba(255,0,0,0), rgba(255,0,0,1));
}
.view18 {
background: repeating-linear-gradient(red, yellow 10%, green 20%);
}
![.view19 {
background: radial-gradient(red, green, blue);
}](https://img-blog.csdnimg.cn/7d650c5d847c4aeea1f88312d053e68e.png)
.view20 {
background: radial-gradient(red 5%, green 15%, blue 60%);
}
.view21 {
background: radial-gradient(circle, red, yellow, green);
}
.view22 {
background: repeating-radial-gradient(red, yellow 10%, green 15%);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。