【问题标题】:Getting unwanted space around contents of html在 html 的内容周围获得不需要的空间
【发布时间】:2015-06-30 18:25:18
【问题描述】:

我的网页内容(无论是标题、菜单等)不适合浏览器窗口。以下是我使用的 HTML 和 CSS 代码

HTML

<div id="header">
</div>

CSS

#header {
height:150px;
width:100%;
position: relative;
background-image: url("top_frame.png");

这是我得到的输出:

【问题讨论】:

  • 不需要的空间在哪里?您可以在JSFiddle 中重现该问题吗?会很有帮助的。
  • 谢谢。不需要的空间是由于正文样式中的边距值不正确!正如 Srinivas Shukla 所说的那样做对了。

标签: html css width spacing


【解决方案1】:

添加以下内容:

body {
    margin: 0;
}

在 CSS 中。

这里是fiddle

出于测试目的,我将background-image 替换为background : red;,因为我没有图像

【讨论】:

    【解决方案2】:

    请在自定义 CSS 之前使用Normalize.css

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-04
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多