为什么我的网页顶部有一个空白?
我确信答案是显而易见的,但我还没有太多地使用 html/css...
浏览器顶部和第一个 div 之间有一个空白。我实在不明白为什么会有这样的差距。我在css中没有使用margin-top或padding-top或border-top,那为什么会有间隙呢?
谢谢!
I'm sure the answer is obvious, but I haven't been working with html/css that much...
There is a gap of white space in between the top of the browser and the first div. I don't really get why the gap is there. I didn't use margin-top or padding-top or border-top in the css, so why is there a gap?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
虽然如果您实际发布一些代码或网站链接将会非常有帮助,但我认为这只是默认填充。大多数浏览器都有默认样式,例如您可能想要清除的
body
等内容。尝试这样的操作:如果这不能解决问题,您将需要提供更多信息。
While it would be extremely helpful if you actually posted some code or a link to the site, I would assume it's just the default padding. Most browsers have default styles for things like
body
that you may want to clear. Try something like this:If that doesn't fix it you'll need to give more information.
如果没有看到任何内容,我想您要么需要清除 body 元素上的默认填充,要么在该 div 中有一个标题标签,这会增加一些额外的好处。
你使用重置吗? http://meyerweb.com/eric/tools/css/reset/
Without seeing anything I'd imagine you either need to clear the default padding on the body element or you have a heading tag in that div that is adding some extra goodness.
Are you using a reset? http://meyerweb.com/eric/tools/css/reset/
如果页面用包装器包装,请使用:
if the page is wrapped with a wrapper, use:
再说一次,有一些背景会很好,但如果这些解决方案不能解决问题,那么就有一个很好的改变,你将成为利润崩溃的受害者。尝试将body的overflow属性设置为auto
Once again, some context would be nice but if these solutions aren't cutting it, then there's a good change your a victim of collapsing margins. Try setting the overflow property of the body to auto
我也有同样的问题。浮动上部 div 解决了这个问题。
I had the same problem. Floating the upper divs solved it.
我也有同样的问题。当我向 div 容器添加 30px 的填充时,它被修复了。我使用了
我的问题发生在我将一些图像设置为我的 div 中的绝对位置(具有相对位置)之后。出于某种原因,出现了间隙,但设置填充对我有用。
I had the same problem. It was fixed when I added 30px of padding to my div container. I used
My problem happened after I set some images to an absolute position in my div (which had a position of relative.) For some reason that gap appeared, but setting the padding worked for me.