【问题标题】:white space and title not being displayed空白和标题未显示
【发布时间】:2014-04-30 06:59:18
【问题描述】:

我的身体和浏览器顶部之间有大约 20 像素的间距。我似乎无法创建一个删除它并创建一个 0 距离。我的标题也没有显示。我似乎无法弄清楚是什么原因造成的。

css:

html, body {
    width: 100%;
    height: 100%;
    margin: 0;

}
.background {
    background-color:#b0a0e6;
}

.wrapper {
    background-color: grey;
    height: 100%;
    width: 75%;
    margin-left: auto;
    margin-right: auto;
}

html:

{% load staticfiles %}


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
    <!-- Base css -->
    <link rel="stylesheet" type="text/css" href="{% static "css/default.css" %}">

  </head>
  <body class="background">
    <div class="wrapper">   
      <h1>Hello, world!</h1>


    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
  </body>
</html>

【问题讨论】:

  • 尝试使用带有 webkit 浏览器的开发工具元素选择器选择顶部间距。另外,请输入padding:0px;margin:0px;
  • @DylanMadisetti 感谢您的回复,但这并没有解决问题 =[
  • 使用项目选择器选择间距应该已经显示了属于 h2 的间距。查看 Normalize CSS 以删除其他默认扭结necolas.github.io/normalize.css

标签: html css django twitter-bootstrap


【解决方案1】:

间距由h1 的默认margin 创建。要删除间距,您可以将h1 的边距设置为0

.wrapper h1{
   margin-top:0
}

DEMOmargin-top:0

overflow:auto 赋予.wrapper,这将保留h1 的边距并移除顶部间距。

DEMOoverflow auto

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-14
    • 1970-01-01
    相关资源
    最近更新 更多