模仿segmentfault的导航条

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

<!DOCTYPE html>
<html>
<head>
   <title>Bootstrap 实例 - 默认的导航栏</title>
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

<!-- 可选的Bootstrap主题文件(一般不用引入) -->
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="/segmentfault_navbar.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
        <script src="http://cdn.bootcss.com/bootstrap-hover-dropdown/2.0.1/twitter-bootstrap-hover-dropdown.min.js"></script>
<link ref="stylesheet" href="/segmentfault_navbar.css">
    
    
</head>
    <body>
        <div class="mynav">
        <div class="container">

            <nav class="navbar navbar-primary">
  <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-example-navbar-collapse-1" 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>
      <a class="navbar-brand" href="#">SegmentFault</a>
    </div>
      
       <form class="navbar-form navbar-left hidden-sm hidden-xs" action="/search" method="post" role="search">
        <div class="input-group">
          <span class="input-group-addon glyphicon glyphicon-search"></span>
          <input type="text" class="form-control my-input-search " placeholder="Search">
           
        </div>
        
      </form>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav my-first-navbar">
        <li class="active"><a href="#">问答 <span class="sr-only">(current)</span></a></li>
        <li><a href="#">文章</a></li>
        <li><a href="#">活动</a></li>
        <li><a href="#">榜单</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">···</a>
          <ul class="dropdown-menu">
            <li><a href="#">笔记</a></li>
            <li><a href="#">职位</a></li>
            <li><a href="#">标签</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
     
      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">撰写<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">提问题</a></li>
            <li><a href="#">写文章</a></li>
            <li><a href="#">做笔记</a></li>
          </ul>
        </li>
        <li><a href="#"><span class="glyphicon glyphicon-envelope"></span></a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <span class="glyphicon glyphicon-user"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">我的主页</a></li>
            <li><a href="#">我的档案</a></li>
            <li><a href="#">我的笔记</a></li>
              <li><a href="#">账号设置</a></li>
              <li><a href="#">草稿箱</a></li>
              <li><a href="#">收藏夹</a></li>
              
            <li role="separator" class="divider"></li>
              <li><a href="#">退出</a></li>
              <li><a href="#">帮助中心</a></li>
              <li><a href="#">建议反馈</a></li>

          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
        </div>
        </div>
        <script >
            var searchBoxWidth = $(".my-input-search").width();
            $(".my-input-search").focusin(
                function () {
                   $(".my-first-navbar").css("display","none");
                    $(".my-input-search").css("width","434px");
                }
            );
            $(".my-input-search").focusout(
                function () {
                   $(".my-first-navbar").css("display","block");
                    $(".my-input-search").css("width",searchBoxWidth);
                }
            );
        
        </script>
    </body>
</html>