有没有办法在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>
答案 0 :(得分:1)
right: 5rem
添加到第二个按钮。divs
,其ID不同(适用于搜索和导航栏链接)。data-target
属性。
.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;