我想要在导航栏下面进行自举式操作

时间:2015-08-08 20:39:44

标签: twitter-bootstrap

我看起来没问题,但在实施其他更改之后,问题似乎又回来了。

请参阅附带的图片,其中包含以下说明:

我想要做的是让我的主页的导航栏位于顶部,并将我的徽标放在它下面,一直到左边。也就是说,我不希望导航栏像现在一样重叠徽标。

我还在下面提供了我的代码。非常感谢任何帮助:

 [![<body>   

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>

        <div class="collapse navbar-collapse" id="bs-navbar">
            <ul class="nav navbar-nav">
                <li><a href="#">Home<span class="sr-only">(current)</span></a>
                </li>
                <li><a href="#">About Us<span class="sr-only">(current)</span></a>
                </li>
                <li><a href="#">Contact Us</a>
                </li>
            </ul><!-- nav navbar-nav -->
            <ul class="nav navbar-nav navbar-right">
                <li><a href="register.php">Register</a></li>
                <li class="divider-vertical"></li>
                <li class="dropdown" >
                    <a href="#" class="dropdown" role="menu" data-toggle="dropdown" >Log In <strong class="caret"></strong></a>
                    <!--<div class="dropdown-menu pull-right" style="padding: 15px; padding-bottom: 10px;">-->
                    <ul class="dropdown-menu" role="menu">
                    <li>
                        <form action="login.php" method="post">
                            <div class="form-group">
                              <label for="username">Username</label>
                              <input class="form-control" type="text" name="username" />
                              <label for="password">Password</label>
                              <input class="form-control" type="password" name="password" />
                              <input class="btn btn-primary" type="submit" name="submit" value="Sign In" />
                            </div>
                        </form>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div><!--container-fluid-->
</nav>

<section class="row">
            <div class="col-xs-12">
            <section class="branding" >          
                <a href="index.php"><img src="/projectx/images/logo1.png" alt="Logo For Project X"></a>             
                <span style="color:red; float:right; margin-top:4%; margin-right: 4%; border: 3px black solid; padding: 3%">        
                </span>
            </section>
            </div>          
</section><!-- branding -->

<!--
<div class="brand"> <a href="#"><img src="images/logo1.png"></a></div>
--> 
<section class="sidebar col col-lg-4">

</section><!-- sidebar -->

    <section class="row">

            <div class="col-xs-12">
            <!--<section class="branding">           
                <a href="index.php"><img src="/projectx/images/logo1.png" alt="Logo For Project X"></a>             

            </section>-->
            </div>

    </section><!-- branding -->

</section><!--sidebar-->

</body>][1]][1]

1 个答案:

答案 0 :(得分:0)

我不确定这是否是您最终要做的事情:创建一个侧边栏,让徽标放在里面,然后使用固定的导航栏滚动。

body,
html,
.row-offcanvas {
  height: 100%;
}
body {
  padding-top: 50px;
}
.navbar .dropdown-menu {
  width: 300px;
  padding: 10px;
}
.navbar .dropdown-menu {
  border-radius: 0;
  box-shadow: none;
  margin-right: -1px;
}
.navbar .dropdown-menu form .form-group .form-control,
.navbar .dropdown-menu form .form-group label,
.navbar .dropdown-menu form .form-group .btn-primary {
  margin: 5px 0;
}
.sidebar-fixed {
  padding: 10px 14px;
  position: fixed;
  width: 120px;
  height: 100%;
  top: 0;
  left: 0;
  /*background: lightgrey;*/
}
.sidebar-fixed img {
  margin-top: 50px;
  border: 3px solid #000;
}
.main-content {
  /*background: lightblue;*/
  margin-left: 110px;
  padding: 10px;
}
@media (max-width: 768px) {
  .navbar .dropdown-menu {
    margin-right: 0;
  }
  .navbar .dropdown-menu form .form-group {
    color: #fff;
  }
  .sidebar-fixed {
    display: none;
  }
  .main-content {
    /*background: lightblue; */
    margin: 20px 0px 0px 0px;
    padding: 10px;
    min-width: 100%;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>

      </button>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-navbar">
      <ul class="nav navbar-nav">
        <li><a href="#">Home<span class="sr-only">(current)</span></a>

        </li>
        <li><a href="#">About Us</a>

        </li>
        <li><a href="#">Contact Us</a>

        </li>
        <li><a href="#">Sign Up</a>

        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>

          <ul class="dropdown-menu" role="menu">
            <li>
              <form action="login.php" method="post">
                <div class="form-group">
                  <label for="username">Username</label>
                  <input class="form-control" type="text" name="username" />
                  <label for="password">Password</label>
                  <input class="form-control" type="password" name="password" />
                  <input class="btn btn-primary" type="submit" name="submit" value="Sign In" />
                </div>
              </form>
            </li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>
<div class="container-fluid">
  <div class="sidebar-fixed">
    <img src="http://placehold.it/100x100/67A7CA/fff?text=logo" />
  </div>
  <div class="main-content">
    <div class="well well-primary">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked
      up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.</div>
    <div class="alert alert-warning" role="alert">Sidebar Warning</div>
    <div class="jumbotron">
      <div class="container">
        <p>Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first
          line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This
          book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de
          Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes
          from a line in section 1.10.32. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular
          during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
      </div>
    </div>
  </div>
</div>