html渐变透明度,CSS3 线性渐变(linear-gradient),半透明+渐变

本文介绍了如何使用CSS来创建不同类型的渐变背景效果,并确保这些效果能在多种浏览器中兼容显示,包括从上到下、从左到右、指定角度及透明渐变等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

不兼容IE浏览器,所以IE中要添加默认的background或background-color1、开始于center(水平方向)和top(垂直方向)也就是Top → Bottom:

/* Firefox 3.6+ */

background-image:-moz-linear-gradient(top, #ace, #f96);

/* Safari 5.1+, Chrome 10+ */

background-image:-webkit-linear-gradient(top, #ace, #f96);

/* Opera 11.10+ */

background-image:-o-linear-gradient(top, #ace, #f96);

2、始于left(水平方向)和center(垂直方向)也是就Left → Right:

/* Firefox 3.6+ */

background-image: -moz-linear-gradient(left, #ace, #f96);

/* Safari 5.1+, Chrome 10+ */

background-image: -webkit-linear-gradient(left, #ace, #f96);

/* Opera 11.10+ */

background-image: -o-linear-gradient(left, #ace, #f96);

3、起始于left(水平方向)和top(垂直方向):

background-image: -moz-linear-gradient(left top, #ace, #f96);

background-image: -webkit-linear-gradient(left top, #ace, #f96);

background-image: -o-linear-gradient(left top, #ace, #f96);

4、角度(Angle):

.deg45 {

background-image: -moz-linear-gradient(45deg, #ace, #f96);

background-image: -webkit-linear-gradient(45deg, #ace, #f96);

background-image: -o-linear-gradient(45deg, #ace, #f96);

}5、变透明+渐变

div{

background-image:linear-gradient(

to bottom

rgba(0,0,0,.6) 0%,

rgba(0,0,0,.3) 50%,

rgba(0,0,0,0) 100%

);

background-image:-webkit-linear-gradient(

to bottom,

rgba(0,0,0,.6) 0%,

rgba(0,0,0,.3) 50%,

rgba(0,0,0,0) 100%

);

}

rgba(0,0,0,0) 50%

rgba(0,0,0,0) 50%

rgba(0,0,0,.6) 0%,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值