您需要在瀏覽器的默認填充和利潤重置爲0使用:
http://meyerweb.com/eric/tools/css/reset/
它是如何工作是所有瀏覽器都默認填充和利潤實現的,並補充說,以你的CSS文件,它會重置所有瀏覽器邊距和填充爲0px。
此代碼將覆蓋你將永遠都瀏覽器的默認程序:
/* 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;
}
究竟!將body和* margin/paddings設置爲零(0) – Tobias 2011-03-10 14:29:31
@Tobiask不鼓勵使用'*',因爲它是瀏覽器密集型的,因此Eric Mayers是一種更有效的方法。 – 2011-03-10 14:31:48