该行大于Bootstrap中的容器

时间:2013-03-31 10:04:36

标签: javascript css twitter-bootstrap containers

我使用Bootstrap时遇到问题。

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Landing Page</title>
  <!-- Bootstrap -->
  <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
  <link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
  <link href="bootstrap/css/custom.css" rel="stylesheet" media="screen">
  <!-- Javascript -->
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
  <script src="bootstrap/js/bootstrap.min.js"></script>
</head>

<body>
  <div class="container">
    <div class="row" id="main_header">
    </div>
  </div>
</body>

</html>

但结果是该行大于容器。

我给你留个照片来理解我的意思

在custom.css中,只有div的高度和颜色。

1 个答案:

答案 0 :(得分:7)

该行不大于容器。它是由响应式设计引起的,它在大于1200px的分辨率上将行margin-left设置为-30px。如果您不想这样,请添加

<style type="text/css">
.row {
  margin-left: 0px;
}
</style>
</head>之前

其他问题:

您的标题应为

<!DOCTYPE html>
<html>

您正在使用oldschool HTML4文档定义。使用HTML5(强烈建议使用bootstrap文档。使用上面的内容,您的页面将在IE中的quirksmode中进行)

此外,使用更新的 jquery ,您的页面将无法使用1.3 - “on”在1.3中不存在,而bootstrap多次引用jquery on 。至少使用1.7.1

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>