从标题中删除空格

时间:2015-08-09 23:17:25

标签: header border space

我用 <div id="help"> <h2>Help</h2> <p>Here are some text for place holder. This will be some random text. Blah blah. No grammar no nothing. How does this work. haha No idea.Here are some text for place holder. This will be some random text. Blah blah. No grammar no nothing. How does this work. haha No idea.Here are some text for place holder. This will be some random text. Blah blah. No grammar no nothing. How does this work. haha No idea.</p> </div> 包裹我的标题和段落。我给了它一个名为help的ID。在css中,我设置了元素的样式,为它提供了标题标签的边框和背景。如何删除边框内标题上方的空白区域?我只知道如何使用边距和填充。

HTML:

#help {
    border: 1px solid black;
    background-color: white;
    width: 20%;
}

CSS:

ExtractTextPlugin

1 个答案:

答案 0 :(得分:0)

您需要删除<h2>元素的默认边距,还需要使用#help正确定位div:

HTML:

    <div id="help">
    <h2>Help</h2>
    <p>Here are some text for place holder. This will be some random text. Blah blah. No grammar no nothing. How does this work. haha No idea.Here are some text for place holder. This will be some random text. Blah blah. No grammar no nothing. How does this work. haha No idea.Here are some text for place holder. This will be some random text. Blah blah. No grammar no nothing. How does this work. haha No idea.</p>  
</div>

<强> CSS:

    #help {
    border: 1px solid black;
    background-color: white;
    width: 20%;
    }

    h2{
    margin-top: 0px;
    }