问题描述
<head>
<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>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins">
<Meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
/ *我试图将徽标放在最左边,居中放置在中心,然后登录到右边。我这样做了,但是汉堡包在移动视图中无法正常工作。它会扩展但不会崩溃* /
<body>
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm nav-font">
<div class="container">
<a href="#">
<img src="/storage/img/msprojectlogo.png" style="width:30%;">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-md-center" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/about">About</a></li>
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/services">Services</a></li>
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/posts">Blog</a></li>
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<li class="nav-item p-1 pl-4">
<a class="nav-link" href="#') }}</a>
</li>
<li class="nav-item p-1 pl-4">
<a class="nav-link" href="#</a>
</li>
</ul>
</div>
</div>
</nav>
解决方法
有效,
您可以添加 Bootstrap CSS CDN
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark shadow-sm nav-font">
<div class="container">
<a href="#">
<img src="https://i.stack.imgur.com/q2xkQ.png" style="width:50%;">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-md-center" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/about">About</a></li>
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/services">Services</a></li>
<li class="nav-item p-1 pl-4"><a class="nav-link" href="/posts">Blog</a></li>
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<li class="nav-item p-1 pl-4">
<a class="nav-link" href="#') }}</a>
</li>
<li class="nav-item p-1 pl-4">
<a class="nav-link" href="#</a>
</li>
</ul>
</div>
</div>
</nav>
</body>