"登录" &安培; "注册"当我点击toogler图标时,选项与可折叠菜单的项目一起使用。我希望"登录" 。 "注册"选项总是处于这个位置。
我的代码:
<nav class="navbar navbar-expand-md navbar-dark bg-primary sticky-top">
<div class="container" >
<button class="navbar-toggler" data-toggle="collapse" data-target="#ourNav">
<i class="navbar-toggler-icon"></i>
</button>
<a href="" class="navbar-brand "> online exam </a>
<div class="collapse navbar-collapse justify-content-center " id="ourNav">
<ul class="navbar-nav ">
<li class="nav-item"><a href="" class="nav-link">Home</a></li>
<li class="nav-item"><a href="" class="nav-link">Your Profile</a></li>
<li class="nav-item"><a href="" class="nav-link">Exam</a></li>
<li class="nav-item"><a href="" class="nav-link">About Us</a></li>
<li class="nav-item "><a href="" class="nav-link">Contact</a></li>
</ul>
</div>
<section class="nav ">
<a href="sign_in.php" class="nav-link text-light">Sign in</a>
<a href="sign_up.php" class="nav-link text-light">Sign up</a>
</section>
</div>
</nav>
答案 0 :(得分:2)
只需将注册部分移到顶部并添加class order-md-3
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<style>
</style>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-primary sticky-top">
<div class="container" >
<button class="navbar-toggler" data-toggle="collapse" data-target="#ourNav">
<i class="navbar-toggler-icon"></i>
</button>
<a href="" class="navbar-brand "> online exam </a>
<section class="nav order-md-3">
<a href="sign_in.php" class="nav-link text-light">Sign in</a>
<a href="sign_up.php" class="nav-link text-light">Sign up</a>
</section>
<div class="collapse navbar-collapse justify-content-center " id="ourNav">
<ul class="navbar-nav ">
<li class="nav-item"><a href="" class="nav-link">Home</a></li>
<li class="nav-item"><a href="" class="nav-link">Your Profile</a></li>
<li class="nav-item"><a href="" class="nav-link">Exam</a></li>
<li class="nav-item"><a href="" class="nav-link">About Us</a></li>
<li class="nav-item "><a href="" class="nav-link">Contact</a></li>
</ul>
</div>
</div>
</nav>
</body>
</html>