保证金弥补 - 没有保证金

时间:2013-11-13 01:44:45

标签: html css margin

我是CSS和网页设计的新手,很抱歉,如果这个问题很天真。

我的边距有问题。我会发布一个JSFiddle,但我的问题没有在JSFiddle上复制。

HTML

 <div class="messed_up_margin">
        <h1>Messed up Margin</h1>
    </div>

CSS

.messed_up_margin{
    margin:0px;
    width:100%;
    color: white;
    backbround: black;
}

.messed_up_margin h1 {
    text-align: center;
}

2 个答案:

答案 0 :(得分:1)

在声明中添加类型。这是PX吗?这是百分比吗? EM?我知道你的意思是零,但它知道吗? (CSS是一个混蛋...)

答案 1 :(得分:0)

我看到你对CSS有点熟悉。浏览器具有自己的样式,可自动应用于元素。只需编写所有六个标头标签并在几个不同的浏览器上打开html文件,然后查看大小和字体差异。

浏览器还具有添加到<body>的样式。因此,您必须告诉浏览器您希望它如何解释<body>。执行此操作的技术称为CSS重置。 Google搜索会为您提供不同的方式but here is a popular one I have seen:

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

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: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}