4

为什么使用 Bootstrap 3.0.0 的内容与品牌不一致?我怎样才能让这些对齐?

在此处输入图像描述

这是我的 HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>Title</title>
        <meta name="viewport" content="width=device-width initial-scale=1.0">
        <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="css/app.css" rel="stylesheet">
    </head>
    <body>
        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container">
                    <span class="navbar-brand">Brand</span>
                </div>
            </div>
        </div>
        <div id="main-region" class="container">
            <p>Content</p>
        </div>

        <script data-main="js/main" src="bower_components/requirejs/require.js"></script>
        <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>    
    </body>
</html>

这是app.css:

body {
    padding-top: 60px;
}
4

1 回答 1

5

您的navbarDIV 需要一个嵌套的containerDIV 才能与您的其他内容对齐。

看看这个例子

它使用以下来源:

<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="container"> <!-- You need this DIV for alignment -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li class="dropdown-header">Nav header</li>
                <li><a href="#">Separated link</a></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
          </ul>
          <form class="navbar-form navbar-right">
            <div class="form-group">
              <input type="text" placeholder="Email" class="form-control">
            </div>
            <div class="form-group">
              <input type="password" placeholder="Password" class="form-control">
            </div>
            <button type="submit" class="btn btn-success">Sign in</button>
          </form>
        </div><!--/.navbar-collapse -->
      </div>
    </div>

    <div class="container">
        <!-- Main content goes here -->
    </div>
</body>
于 2013-08-30T19:20:10.497 回答