-1

このデータを使用して新しい単純なドキュメントを作成しました

HTML

<body>
<div class="header"></div>
</body>

CSS

.header {
    background-color:#000;
    width:100%;
    height:150px;   
}

そして、それは次のように表示されます: 画像

追加のスペースは画像ではっきりと確認できます

私は使用のようないくつかの解決策を見つけました

* {
margin:0;
padding:0;
}

または使用して

.header {
position:absolute;
    top:0px;
    right:0px;
    left:0px;
}

この余分なスペースを削除する他の方法はありますか?

4

2 に答える 2

2

ブラウザによってbodyは、デフォルトの量のパディングまたはマージンが適用されています。それを削除するには、次のようにします。

body { padding: 0; margin: 0; }
于 2013-10-23T23:35:15.460 に答える
0

このCSSコードを追加するだけです

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font-style: normal;
    vertical-align: baseline;
    outline:0;
}
h1,
h2,
h3,
h4,
h5{
    font-weight: normal;    
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
于 2013-10-23T23:39:35.973 に答える