當你默認了<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