css背景图片渐变色怎么设置

html-css012

css背景图片渐变色怎么设置,第1张

background: #000000

background: -moz-linear-gradient(top, #000000 0%, #ffffff 100%)

background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#000000), color-stop(100%,#ffffff))

background: -webkit-linear-gradient(top, #000000 0%,#ffffff 100%)

background: -o-linear-gradient(top, #000000 0%,#ffffff 100%)

background: -ms-linear-gradient(top, #000000 0%,#ffffff 100%)

background: linear-gradient(to bottom, #000000 0%,#ffffff 100%)

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#ffffff',GradientType=0 )

使用css3可以做。

<style>

div {

box-sizing:border-box

width:400px

height:240px

font-size:22px

padding-top:100px

overflow:hidden

background:no-repeat center top / 100% 100%

background-image:linear-gradient(to top, rgba(255,255,255,1), rgba(255,255,255,0)), url(背景图片路径写在这)

}

</style>

<div>

文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字

</div>

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<style>标签中,输入css代码:

div{width:200pxheight:150pxbackground:linear-gradient(red,white)}

3、浏览器运行index.html页面,此时td中的div的背景颜色从红色到白色渐变。