Bootstrap 4:如何在移动设备上获得2个切换图标?

时间:2017-01-28 18:33:00

标签: css twitter-bootstrap bootstrap-4 twitter-bootstrap-4

有没有办法在bootstrap 4的导航栏中获取另一个图标和可折叠下拉列表?我需要它在默认切换图标的左侧。

这是我当前的设置(忽略if语句)。我正在尝试将搜索放在自己的可折叠下拉列表中,并在移动设备上显示自己的图标,同时仍然在当前下拉列表中显示其他导航项。(我现在可以使用默认的引导程序图标)

尝试使我的看起来类似于monster.com导航栏,所以看一看他们的参考。

<div class="container-fluid">
        <nav class="navbar fixed-top navbar-toggleable-md navbar-inverse" style="background-color: #3c763d!important;">

            <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>


            <div id="logo">
                <a class="navbar-brand" href="/">Company Name</a>
            </div>


            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav mr-auto mx-auto">

                    <form class="form-inline">
                        <input class="form-control" type="text" placeholder="Search for job">
                        <input class="form-control" type="text" placeholder="Location" />
                        <button class="btn btn-seconday " type="submit">Search</button>
                    </form>

                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item"><a href="/post" class="nav-link">Post a Job</a></li>

                    <li v-if="!user_logged" class="nav-item">
                        <a href="/signup" class="nav-link"><strong>Sign Up</strong></a>
                    </li>

                    <li v-if="user_logged && user_type === 'user'" class="nav-item">
                        <a href="/profile" class="nav-link"><strong>Profile</strong></a>
                    </li>

                    <li v-if="user_logged && user_type === 'company'" class="nav-item">
                        <a href="/dashboard" class="nav-link"><strong>Employer Dashboard</strong></a>
                    </li>

                    <li v-if="!user_logged" class="nav-item">
                        <a href="/login" class="nav-link"><strong><span class="glyphicon glyphicon-log-in"></span> Login</strong></a>
                    </li>

                    <li v-if="user_logged" class="nav-item">
                        <a href="/logout" class="nav-link"><strong><span class="glyphicon glyphicon-log-out"></span> Logout</strong></a>
                    </li>
                </ul>
            </div>
        </nav>




    </div>

1 个答案:

答案 0 :(得分:1)

  1. 向HTML添加第二个按钮(您可以使用FontAwesome图标设置搜索图标而不是纯文本)。
  2. right: 5rem添加到第二个按钮。
  3. 将导航栏划分为两个divs,其ID不同(适用于搜索和导航栏链接)。
  4. 为您的按钮添加不同的data-target属性。
  5. 你很高兴。

  6. &#13;
    &#13;
    .navbar-toggler.navbar-toggler-custom {
      right: 5rem;
    }
    &#13;
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
    
    <div class="container-fluid">
      <nav class="navbar fixed-top navbar-toggleable-md navbar-inverse" style="background-color: #3c763d!important;">
    
        <button class="navbar-toggler navbar-toggler-right navbar-toggler-custom" type="button" data-toggle="collapse" data-target="#searchNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
          Search
        </button>
    
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
    
    
        <div id="logo">
          <a class="navbar-brand" href="/">Company Name</a>
        </div>
    
    
        <div class="collapse navbar-collapse" id="searchNav">
          <ul class="navbar-nav mr-auto mx-auto">
    
            <form class="form-inline">
              <input class="form-control" type="text" placeholder="Search for job">
              <input class="form-control" type="text" placeholder="Location" />
              <button class="btn btn-seconday " type="submit">Search</button>
            </form>
    
          </ul>
        </div>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav ml-auto">
            <li class="nav-item ml-auto ml-auto"><a href="/post" class="nav-link">Post a Job</a>
            </li>
    
            <li v-if="!user_logged" class="nav-item">
              <a href="/signup" class="nav-link"><strong>Sign Up</strong></a>
            </li>
    
            <li v-if="user_logged && user_type === 'user'" class="nav-item">
              <a href="/profile" class="nav-link"><strong>Profile</strong></a>
            </li>
    
            <li v-if="user_logged && user_type === 'company'" class="nav-item">
              <a href="/dashboard" class="nav-link"><strong>Employer Dashboard</strong></a>
            </li>
    
            <li v-if="!user_logged" class="nav-item">
              <a href="/login" class="nav-link"><strong><span class="glyphicon glyphicon-log-in"></span> Login</strong></a>
            </li>
    
            <li v-if="user_logged" class="nav-item">
              <a href="/logout" class="nav-link"><strong><span class="glyphicon glyphicon-log-out"></span> Logout</strong></a>
            </li>
          </ul>
        </div>
      </nav>
    
    
    </div>
    &#13;
    &#13;
    &#13;