将Bootstrap Navbar项目更改为" hamburger icon"在一定的宽度

时间:2016-06-03 23:43:13

标签: jquery html css twitter-bootstrap

所以我一直试图让我的网站的导航栏项目变成一个"汉堡包图标"浏览器窗口变得足够薄之后。 这是我的HTML:



<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<nav id="nav_bar" class="navbar navbar-custom">
  <a href="index.html" class="navbar-brand">Austin Okray</a>
  <div class="container-fluid">
    <div class="collapse navbar-collapse" id="navbar">
      <ul class="nav navbar-nav">
        <li><a href="ResumeStuff/Resume.pdf" target="_blank">My Resume</a></li>
        <li><a href="pythoncode.html">Python In-browser</a></li>
        <li><a href="fullcode.html">Download Full Code</a></li>
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Internet Presence<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="https://www.linkedin.com/in/austin-okray-7b578a106">LinkedIn</a></li>
            <li><a href="https://twitter.com/austin__okray">Twitter</a></li>
            <li><a href="https://github.com/aokray">Github</a></li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
&#13;
&#13;
&#13;

谢谢!

2 个答案:

答案 0 :(得分:0)

如果您使用Bootstrap,则可以制作两个导航栏。使用汉堡包隐藏/展示自己的东西和一个看起来很简单的东西。使用课程.visible-xs-*标记汉堡包导航,使用课程.hidden-xs标记常规导航。

更多信息:http://getbootstrap.com/css/#responsive-utilities

答案 1 :(得分:0)

我已使用this example作为样本。请检查此代码:

&#13;
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<nav id="nav_bar" class="navbar navbar-default">
  <div class="container-fluid">
   <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" 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 href="index.html" class="navbar-brand">Austin Okray</a>
    </div>
    
    <div class="collapse navbar-collapse" id="navbar-collapse">
      <ul class="nav navbar-nav">
        <li><a href="ResumeStuff/Resume.pdf" target="_blank">My Resume</a></li>
        <li><a href="pythoncode.html">Python In-browser</a></li>
        <li><a href="fullcode.html">Download Full Code</a></li>
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Internet Presence<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="https://www.linkedin.com/in/austin-okray-7b578a106">LinkedIn</a></li>
            <li><a href="https://twitter.com/austin__okray">Twitter</a></li>
            <li><a href="https://github.com/aokray">Github</a></li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
&#13;
&#13;
&#13;