我一直在处理一个小型博客表单,但我的Div标签出现问题。每当我创建第二个div标签来保存表单时,它与前一个Div标签之间就会出现一个空格。我的CSS有什么问题吗?
body {
background-image: url(../images/body-bg.jpg);
font-family: arial;
}
#header {
background-image: url(../images/new-post-h.png);
background-repeat: no-repeat;
height: 124px;
width: 850px;
color: #ffffff;
margin: 0em 0px;
}
#form-bg {
background-image: url(../images/new-post-b.png);
background-repeat: no-repeat;
height: 500px;
width: 850px;
padding: 8px;
margin: 0em 0px;
}
#new-form {
height: 624px;
width: 850;
margin-left: auto;
margin-right: auto;
}
以下是不断发生的事情: http://i40.tinypic.com/j623i8.jpg
答案 0 :(得分:1)
两件事:
1)从你的图像看起来(假设它是100%的大小,你的标题是什么元素等),你的标题背景只有~50px高。但是,您在CSS中将高度定义为124px。你无法用CSS拉伸背景图像(据我所知),因此图像不会填充元素的大小。
2)在#new-form
的声明中,将单位添加到width
。否则,它将无法按预期工作,并且您还将获得解析器错误。