没有白色空间的简单的背景颜色div

时间:2012-07-03 20:47:42

标签: whitespace css

尝试创建背景颜色为白色的内容框。它位于标题div和footer div之间,它们都是图像。我不能让它与两个div对齐并且没有空格,只有一个或另一个。

这是CSS:

#content {
    background-color:#ffffff;
    width:1024px; 
    margin: 0 auto; 
    font-family:Verdana, Geneva, sans-serif;
    font-size:12px;
    padding: 0;
    display: inline-block;
}

如何让内容框与页面的其余部分对齐并且没有任何空格?

这就是目前的样子,我想摆脱HELLO盒子和它上面和下面的图像之间的空间。

This is what it looks like at the moment, I want to get rid of the space between the HELLO box and the images above and below it.

2 个答案:

答案 0 :(得分:2)

这对我来说似乎不是一个干净的解决方案,但我在这里:

#content { 
margin-top: -15px; margin-bottom: -15px; 
}

实际上我不知道-15px是否足够好,你应该尝试自己的价值观。

答案 1 :(得分:1)

这不是一个很好的解决方案,但是根据给定的信息,它是我能想出的唯一一个。

<强> CSS

#content {
    background-color:#ffffff;
    width:1024px; 
    margin: 0 auto; 
    font-family:Verdana, Geneva, sans-serif;
    font-size:12px;
    padding: 0;
    display: inline-block;

    position:relative;
}

#topWhiteFix, #botWhiteFix {
    position:absolute;
    left:0px;
    height:12px;
    width:100%;
    background:#FFFFFF;
}

#topWhiteFix {
    top:-12px;
}

#botWhiteFix {
    bottom:-12px;
}

<强> HTML

<div id="content">
     <div id="topWhiteFix"></div>
     <div id="botWhiteFix"></div>

     HELLO
</div>

(未测试的)

相关问题