我尝试在网站正文中添加背景,我想展示完整背景,并将网站内容集中在其中。
我使用了以下CSS,但无法居中:
body {
margin: auto;
background: url(../images/bggeneral.jpg) top center repeat;
background-position: center;
font-size: 100%;
line-height: 1.0625em;
color: #515151;
width: 100%;
}
背景图片:http://www.comicar.ma/assets/images/bggeneral.jpg
我是否需要裁剪图像或类似的东西?
答案 0 :(得分:4)
如果您不想重复身体图像,可以删除repeat
。 margin:0 auto
应该被赋予容器div。
<强> HTML 强>
<div class="wrapper">
Content
</div>
<强> CSS 强>
body {background: url(http://www.comicar.ma/assets/images/bggeneral.jpg) top center no-repeat; font-size: 100%; line-height: 1.0625em; color: #515151; width: 100%; }
.wrapper{width:700px; margin:0 auto}