该行大于Bootstrap中的容器

Mar*_*ari 2 javascript css containers twitter-bootstrap

我使用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>
Run Code Online (Sandbox Code Playgroud)

但结果是行大于容器.

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

http://i50.tinypic.com/2dvsah3.png

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

dav*_*rad 7

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

<style type="text/css">
.row {
  margin-left: 0px;
}
</style>
Run Code Online (Sandbox Code Playgroud)

之前</head>.

其他问题 :

你的标题应该是

<!DOCTYPE html>
<html>
Run Code Online (Sandbox Code Playgroud)

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

此外,使用更新的jquery,您的页面将无法使用1.3 - " on"在1.3中不存在,并且bootstrap on多次引用jquery .至少使用1.7.1

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)