删除HTML和正文之间的空白或空格[重复项]

问题描述 投票:-1回答:4

此问题已经在这里有了答案:

我通过create-next-app appname方法创建了一个Next.js应用。我运行它没有任何变化。在html和body之间显示如下图所示的空白。我不知道为什么,因为那里没有诸如边距或填充的设置。如何删除此空白/间隙?感谢您审核我的问题。

enter image description here

html css whitespace next.js document-body
4个回答
6
投票

请尝试以下操作,因为,主体具有默认边距:http://www.w3.org/TR/CSS2/sample.html

body { margin:0; } /* Remove body margins */

或使用全局重置

* { margin:0; padding:0; box-sizing:border-box; }

如果您想要的不是*全球性的东西,则为:

html, body, body div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, hgroup, menu, nav, section, time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-size: 100%;
    vertical-align: baseline;
    background: transparent;
}

3
投票

的确!我的网站周围的白色边框到底是什么老问题?在您的.CSS文件顶部始终使用以下代码,您将一臂之力:

html,
body {
   margin: 0;
   padding: 0;
}

2
投票

请添加边距:0;和padding:0;到HTML和CSS中的正文。

最好使用reset.css从元素中删除默认边距和填充。https://meyerweb.com/eric/tools/css/reset/


0
投票
margin-top:0;  /*use this code in your div*/
© www.soinside.com 2019 - 2024. All rights reserved.