twitter-bootstrap – bootstrap 4导航栏导航标签

前端之家收集整理的这篇文章主要介绍了twitter-bootstrap – bootstrap 4导航栏导航标签前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在bootstrap 4中,我尝试使用固定的底部导航栏,当单击链接时,使用的内容来自4个选项卡.
回到早期的引导程序,我曾经工作但试图让它与4一起工作并不适合我.有人能指出我在这里错过的方向吗?
<!DOCTYPE html>
<html lang="en">
  <head>
  <Meta charset="utf-8">
  <Meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  <Meta name="description" content="">
  <Meta name="author" content="">
  <link rel="icon" href="../../../../favicon.ico">

  <title>Starter Template for Bootstrap</title>

  <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

  <!-- Custom styles for this template -->
  <style type="text/css">
      body {
          padding-top: 5rem;
      }

      .starter-template {
          padding: 3rem 1.5rem;
          text-align: center;
      }
  </style>
</head>


  <body>

    <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-bottom">
      <a class="navbar-brand" href="#">title</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
              <a class="nav-link" href="#tab1">test1</a>
          </li>
          <li class="nav-item">
             <a class="nav-link" href="#tab2" data-toggle="tab">test2</a>
          </li>
          <li class="nav-item">
             <a class="nav-link" href="#tab3" data-toggle="tab">test3</a>
          </li>
          <li class="nav-item">
             <a class="nav-link" href="#tab4" data-toggle="tab">test4</a>
          </li>
        </ul>
      </div>
    </nav>

    <main role="main" class="container">
      <h2>title</h2>
      <div class="tab-content">
        <div class="tab-pane active" id="tab1">
          <h4>test1</h4>
          tab1
        </div>
        <div class="tab-pane" id="tab2">
          <h4>test2</h4>
          tab2
        </div>
        <div class="tab-pane" id="tab3">
          <h4>test3</h4>
          tab3
        </div>
          <div class="tab-pane" id="tab4">
          <h4>test4</h4>
        </div>
      </div>
    </main>
    <!-- /.container -->
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>

解决方法

您只需要在navbar-nav中包含nav类…

演示:https://www.codeply.com/go/IzQdCtwy78

<ul class="navbar-nav nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="#tab1">test1</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#tab2" data-toggle="tab">test2</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#tab3" data-toggle="tab">test3</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#tab4" data-toggle="tab">test4</a>
            </li>
       </ul>
原文链接:https://www.f2er.com/bootstrap/234001.html

猜你在找的Bootstrap相关文章