莱芜美食
您的当前位置:首页背景图跟随界面大小而改变_html/css

背景图跟随界面大小而改变_html/css

来源:莱芜美食
 背景图 自动变化 CSS

有一张比较大的背景图2000×8
利用css设置为页面的背景
CSS如下:
body {text-align: left; font-family:"新宋体"; margin:auto;padding:0;
font-size:12px;color:#0C0C0C; background-color: #FFF;
BACKGROUND:url(../images/bj.gif) no-repeat;background-position: top center;}

请教大虾要怎么做可以让背景图片根据页面的大小而自动调整大小,始终显示全图,而不是一部分?


回复讨论(解决方案)

图片随着页面的大小而改变,
.css{
width: 100%;
position: absolute;
margin-right: auto;
margin-left: auto;
}



body {padding:0;margin:0;}img { position:absolute;width:100%;height:100%;z-index:-999;}

使用background的方式好像不能实现,等待高手讲解background实现方式。

显示全文