Navbar bootstrap网站

时间:2017-07-05 22:25:34

标签: javascript jquery html css twitter-bootstrap

上午尝试使用bootstrap创建一个网站,我希望它在顶部和导航栏上有一个标题,如果是滚动我的导航栏固定在第一页上显示的标题当我移动到我想看的其他页面时只有导航栏固定在顶部,我的所有导航栏链接都在同一页面上我的代码是

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Urbanic Home</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body>
    <div class="fad-top-bar"  id="fad-top">
      <div class="container">
      <div class="top">
        <div class="pull-left" id="phone">
          <img src="img/phone.png" alt="phone">
          00000000000
        </div>
        <div class="pull-right" id="email">
          <img src="img/email.png" alt="email">
          @outlook.com
        </div>
        </div>
      </div>
    </div>

    <div class="fad-top-menu">
      <div class="container">
        <nav class="navbar navbar-default" role="navigation">
          <div class="navbar-header">
            <button type="button" class=" collapsed navbar-toggle" data-toggle="collapse" data-target="#myNavbar" aria-expanded="false" aria-controls="myNavbar">
              <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="#" class="navbar-brand"><img src="img/logo.png" alt="Urbanic Fadsoft Investments" title="Urbanic Fadsoft Investments"></a>    
          </div>
          <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar-nav navbar-right" style="margin-top: 25px;">
              <li class="active"><a href="#fad-top">HOME</a></li>
              <li><a href="#fad-about">ABOUT</a></li>
              <li><a href="#fad-portfolio">PORTFOLIO</a></li>
              <li><a href="#fad-blog">BLOG</a></li>
              <li><a rel="follow" href="http://www.facebook.com/fadsoft Investments" 
               class="external-link" target="_parent">EXTERNAL</a></li>
              <li><a href="#fad-contact">CONTACT</a></li>
            </ul>
          </div>
        </nav>
      </div>  
    </div>

1 个答案:

答案 0 :(得分:0)

.navbar-fixed-top添加到您的nav代码中,使其保持固定在顶部。 所以在代码中更改它。

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">

以下是文档:navbar-fixed-top