杂色的背景,CSS中如何写

html-css014

杂色的背景,CSS中如何写,第1张

什么叫杂色的背景?

楼主请附图

如果是有这样规则渐变背景(如上图),可用一段背景图片平铺而成

也可以用css3最新渐变背景样式(当然考虑到兼容性),代码如下

.gradient{

width:300px

height:150px

filter:alpha(opacity=100 finishopacity=50 style=1 startx=0,starty=0,finishx=0,finishy=150) progid:DXImageTransform.Microsoft.gradient(startcolorstr=red,endcolorstr=blue,gradientType=0)

-ms-filter:alpha(opacity=100 finishopacity=50 style=1 startx=0,starty=0,finishx=0,finishy=150) progid:DXImageTransform.Microsoft.gradient(startcolorstr=red,endcolorstr=blue,gradientType=0)/*IE8*/

background:red /* 一些不支持背景渐变的浏览器 */

background:-moz-linear-gradient(top, red, rgba(0, 0, 255, 0.5))

background:-webkit-gradient(linear, 0 0, 0 bottom, from(#ff0000), to(rgba(0, 0, 255, 0.5)))

background:-o-linear-gradient(top, red, rgba(0, 0, 255, 0.5))

}

<div class="gradient"></div>

如果没有规律只能用背景图片方法了

background:url(bg.jpg) no-repead

比如url(images/nan_bg_o.jpg)这是背景图的css写法,它的正则表达式如下

VBScript codes=".x{background:url(images/nan_bg_o.jpg)}.xx{}.xxx{background: URL(images/nan_bg_oxx.jpg) }"

set rx=new RegExp

rx.IgnoreCase=true

rx.Global=true

rx.Pattern="url\s*\(([^\)]+)\)"

set mc=rx.Execute(s)

for each m in mc

response.Write "<pre>"&m.submatches(0)&"</pre>"

next

set rx=nothing