当你默认了<body>
和其他一些元素,如段落标记(<p>
),标题标签(<h1>
,<h2>
... <h6>
)等创建一个HTML页面...有默认padding
和margins
所以你需要通过添加以下CSS来清除这些保证金:
html, body, p, h1, h2, h3, h4, h5, h6 {
margin:0;
padding:0;
}
详情见CSS RESET
复位样式表的目的是减少之类的东西默认的行高度,页边距和标题的字体大小,等浏览器的不一致性。
一个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: inherit;
vertical-align: baseline;
}
嗨..欢迎来到SO ..你能不能给我们展示更多的代码..或者,也许你可以在JSFiddle.net上创建一个小提琴来展示它。 –
你使用什么浏览器? – Michael
我正在使用chrome – agassi0430