使用col-md-offset时出现水平滚动

时间:2015-07-10 08:48:30

标签: html twitter-bootstrap

当我使用 bootstrap col-md-offset-2时,水平滚动条出现在窗口视图和移动视图中。我不知道这个水平滚动条在我的网站上是如何出现的。

请帮帮我。 谢谢......

的index.html

<!DOCTYPE html>
<html>
<head>

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/norwich.css">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
      <![endif]-->

  </head>

  <body>
    <!-- header -->
    <div class="row">
    <div class="col-md-offset-2 col-md-8">
          <header>
            <nav class="navbar navbar-inverse" role="navigation">
              <div class="navbar-header">
                <div class="container">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse">
                    <span class="sr-only">Toggle Navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a href="#"><h1>LOGO</h1></a>
            </div>
        </div>
        <div class="collapse navbar-collapse" id="example-navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
             <li><a >HOME</a></li>
             <li><a >ABOUT</a></li>
             <li><a >SKIP HIRE</a></li>
             <li><a >CONTACT</a></li>
         </ul>
     </div>
 </nav>
</header>
</div>
</div>

<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>

</body>
</html>

2 个答案:

答案 0 :(得分:0)

使用

包围所有代码
<div class="container-fluid"></div>

Here is a JSFiddle demo

答案 1 :(得分:0)

嗨,当你在

后面没有容器时

&#13;
&#13;
<div class="row"></div>
&#13;
&#13;
&#13;

它将处于负边缘。

所以你可以这样做。

&#13;
&#13;
<!-- header -->
          <header>
            <nav class="navbar navbar-inverse col-md-offset-2 col-md-8" role="navigation">
              <div class="navbar-header">
                <div class="container">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse">
                    <span class="sr-only">Toggle Navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a href="#"><h1>LOGO</h1></a>
            </div>
        </div>
        <div class="collapse navbar-collapse" id="example-navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
             <li><a >HOME</a></li>
             <li><a >ABOUT</a></li>
             <li><a >SKIP HIRE</a></li>
             <li><a >CONTACT</a></li>
         </ul>
     </div>
 </nav>
</header>
&#13;
&#13;
&#13;