css怎么定义页面背景为横条

html-css016

css怎么定义页面背景为横条,第1张

1、做一个合适的横条图片,放到空间下,如下图

2、新建CSS样式,取好样式名。

3、在CSS规则定义下,在“Background-color”后选择刚才的图片。

4、在Background-repeat下选择“repeat”,这是说明让背景图重复平铺。

5、定义好DIV方框的宽和高。

6,看效果,符代码“background-image: url(11.fw.png)background-repeat: repeat”

刚手写的,希望是你要的效果;可以兼容不同浏览器的水平和垂直居中

<body style="margin:0padding:0">

<div style="height:1pxbackground-color:#000position:absolutetop:50%left:0pxwidth:100%"></div>

<div style=" background-color:#000position:absolutetop:50%left:50%width:200pxheight:100pxmargin:-50px 0 0 -100pxbackground-color:#00FFCC">插入图片</div>

</body>

如果你要做的是一个页面的某一部分的话,那就调整top的值,设为固定值就行了