html中怎样写渐变色代码,css如何实现渐变效果?

一、css背景色渐变样式

1.css线性背景渐变样式

语法:

background-image:linear-gradient(||,,,)

第一个参数是渐变起始点或角。第二个参数是一种颜色停止点(colorstops)。至少需要两种颜色(起点和终点),你可以添加任意种颜色来增加颜色渐变的丰富程度。对颜色停止点的定义可以是一种颜色,或一种颜色加一个百分比。

代码(考虑浏览器兼容性):

css背景渐变--线性渐变

.demo{

width:500;

height:300;

margin:50pxauto;

}

.demo*{

width:200px;

height:200px;

margin:20px;

text-align:center;

line-height:200px;

color:#fff;

font-size:16px;

float:left;

}

.demo1{

/*底色*/

background-color:#fd0d0d;

/*chrome2+,safari4+;multiplecolorstops*/

background-image:-webkit-gradient(linear,leftbottom,lefttop,color-stop(0.32,#fd0d0d),color-stop(0.66,#d89e3c),color-stop(0.83,#97bb51));

/*chrome10+,safari5.1+*/

background-image:-webkit-linear-gradient(#fd0d0d,#d89e3c,#97bb51);

/*firefox;multiplecolorstops*/

background-image:-moz-linear-gradient(top,#fd0d0d,#d89e3c,#97bb51);

/*ie6+*/

filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fd0d0d',endColorstr='#d89e3c');

/*ie8+*/

-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr='#fd0d0d',endColorstr='#d89e3c')";

/*ie10*/

background-image:-ms-linear-gradient(#fd0d0d,#d89e3c,#97bb51);

/*opera11.1*/

background-image:-o-linear-gradient(#fd0d0d,#d89e3c,#97bb51);

/*标准写法*/

background-image:linear-gradient(#fd0d0d,#d89e3c,#97bb51);

}

.demo2{

/*底色*/

background-color:#d41a1a;

/*chrome2+,safari4+;multiplecolorstops*/

background-image:-webkit-gradient(linear,leftbottom,righttop,color-stop(0.32,#d41a1a),color-stop(0.66,#d9e60c),color-stop(0.83,#5c7c99));

/*chrome10+,safari5.1+*/

background-image:-webkit-linear-gradient(45deg,#d41a1a,#d9e60c,#5c7c99);

/*firefox;multiplecolorstops*/

background-image:-moz-linear-gradient(45deg,#d41a1a,#d9e60c,#5c7c99);

/*ie10*/

background-image:-ms-linear-gradient(45deg,#d41a1a0%,#d9e60c100%);

/*opera11.1*/

background-image:-o-linear-gradient(45deg,#d41a1a,#d9e60c);

/*标准写法*/

background-image:linear-gradient(45deg,#d41a1a,#d9e60c);

}

基本线性渐变--自上而下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值