今天重写模板的时候需要用到这个效果,线性渐变,属于CSS3 linear-gradient写法!
之前已经写过一篇关于:CSS3 经典教程系列:CSS3 线性渐变(linear-gradient)
案例HTML代码:
<div class="box"> <div class="bg"></div> <div class="img"> img+p </div> <div class="cname"> catename </div> </div>
CSS:
.box{width: 100%;height: 165px;position: relative;}
.box .bg{position: absolute;left: 0;top: 0;right: 0;bottom: 0;
background: -webkit-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.4)); /*Safari、Chrome*/
background: -moz-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.4)); /*Firefox,Flock*/
background: -o-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.4)); /*Opera*/
background: linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.4));
}
.box:hover .bg{
background: -webkit-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.2));
background: -moz-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.2));
background: -o-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.2));
background: linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.2));
}
版权说明:Copyright © 广州松河信息科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州松河信息科技有限公司 版权所有