如何在bootstrap中添加汉堡菜单

muk1a3rh  于 2023-08-01  发布在  Bootstrap
关注(0)|答案(3)|浏览(135)

我需要一些引导导航的帮助。我希望它是通过移动的汉堡图标切换。
下面是codepen:http://codepen.io/sadman/pen/hfGwv(链接无效)

.navbar,
.navbar-inverse {
  border-radius: 0;
  border: none;
  margin-bottom: 0;
  min-height: 80px;
}

.nav li {
  display: inline;
  color: white;
}

.navbar-inverse .navbar-nav>li>a {
  color: #ffffff;
  font-family: Lato;
  font-size: 1.7em;
  font-weight: 300;
  padding: 30px 25px 33px 25px;
}

.navbar-inverse .navbar-nav li a:hover {
  background-color: #444444;
  transition: 0.7s all linear;
  height: 100%;
}

个字符

pod7payv

pod7payv1#

你所要做的就是阅读getbootstrap.com上的代码:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">

<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <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-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="index.php">Home</a></li>
        <li><a href="about.php">About</a></li>
        <li><a href="#portfolio">Portfolio</a></li>
        <li><a href="#">Blog</a></li>
        <li><a href="contact.php">Contact</a></li>
      </ul>
    </div>
  </div>
</nav>

字符串

oyt4ldly

oyt4ldly2#

  • 要创建图标,您可以在Bootstrap中使用Glyphicon:*
<a href="#" class="btn btn-info btn-sm">
    <span class="glyphicon glyphicon-menu-hamburger"></span>
</a>

字符串

  • 然后在css中控制图标的大小:*
.glyphicon-menu-hamburger {
  font-size: npx;
}

3xiyfsfu

3xiyfsfu3#

仅CSS(无图标集)Codepen

.nav-link #navBars {
margin-top: -3px;
padding: 8px 15px 3px;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}

.nav-link #navBars input {
display: none;
}

.nav-link #navBars span {
position: relative;
z-index: 1;
display: block;
margin-bottom: 6px;
width: 24px;
height: 2px;
background-color: rgba(125, 125, 126, 1);
border-radius: .25rem;
}

个字符

相关问题