body{}{
FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#ffffff,endColorStr=#000000)"
}
二、从左上至右下渐变
body{}{
FILTER: Alpha( style=1,opacity=25,finishOpacity=100,startX=50,finishX= 100,startY=50,finishY=100)
background-color: skyblue
}
三、从左往右渐变
body{}{
FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=#ffffff,endColorStr=#000000)"
}
CSS3 渐变(gradients)可以让你在两个或多个指定的颜色之间显示平稳的过渡。
CSS3 定义了两种类型的渐变(gradients):线性渐变(Linear Gradients)- 向下/向上/向左/向右/对角方向与径向渐变(Radial Gradients)- 由它们的中心定义
线性渐变:
3.1、从上到下的线性渐变:
#grad {
background: -webkit-linear-gradient(red, blue)/* Safari 5.1 - 6.0 */
background: -o-linear-gradient(red, blue)/* Opera 11.1 - 12.0 */
background: -moz-linear-gradient(red, blue)/* Firefox 3.6 - 15 */
background: linear-gradient(red, blue)/* 标准的语法 */
}
3.2、从左到右的线性渐变:
#grad {
background: -webkit-linear-gradient(left, red , blue)/* Safari 5.1 - 6.0 */
background: -o-linear-gradient(right, red, blue)/* Opera 11.1 - 12.0 */
background: -moz-linear-gradient(right, red, blue)/* Firefox 3.6 - 15 */
background: linear-gradient(to right, red , blue)/* 标准的语法 */
}
3.3、线性渐变 - 对角:
#grad {
background: -webkit-linear-gradient(left top, red , blue)/* Safari 5.1 - 6.0 */ background: -o-linear-gradient(bottom right, red, blue)/* Opera 11.1 - 12.0 */ background: -moz-linear-gradient(bottom right, red, blue)/* Firefox 3.6 - 15 */ background: linear-gradient(to bottom right, red , blue)/* 标准的语法 */
}
4.径向渐变:
4.1、颜色结点均匀分布的径向渐变:
#grad {
background: -webkit-radial-gradient(red, green, blue)/* Safari 5.1 - 6.0 */ background: -o-radial-gradient(red, green, blue)/* Opera 11.6 - 12.0 */
background: -moz-radial-gradient(red, green, blue)/* Firefox 3.6 - 15 */
background: radial-gradient(red, green, blue)/* 标准的语法 */
}
4.2、颜色结点不均匀分布的径向渐变::
#grad {
background: -webkit-radial-gradient(red 5%, green 15%, blue 60%)/* Safari 5.1 - 6.0 */
background: -o-radial-gradient(red 5%, green 15%, blue 60%)/* Opera 11.6 - 12.0 */
background: -moz-radial-gradient(red 5%, green 15%, blue 60%)/* Firefox 3.6 - 15 */ background: radial-gradient(red 5%, green 15%, blue 60%)/* 标准的语法 */
}
4.3、形状为圆形的径向渐变:
#grad {
background: -webkit-radial-gradient(circle, red, yellow, green)/* Safari 5.1 - 6.0 */ background: -o-radial-gradient(circle, red, yellow, green)/* Opera 11.6 - 12.0 */ background: -moz-radial-gradient(circle, red, yellow, green)/* Firefox 3.6 - 15 */ background: radial-gradient(circle, red, yellow, green)/* 标准的语法 */
}