在手机上查看时,导航栏不会变小。 ! https://imgur.com/a/XIs5X6m“示例”
<!-- Navigation -->
<nav class="navbar navbar-expand-lg fixed-top text-uppercase bg-inverse" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top"><img style="height: 80px;" src="img/logobanner.png" alt=""></a>
<button class="navbar-toggler navbar-toggler-right text-uppercase bg-primary text-white rounded" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#page-top">Home</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#about">2</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#portfolio">Foto's</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#portfolio2">Agenda</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#contact">Boeken</a>
</li>
</ul>
</div>
</div>
</nav>
在电话上查看时,您可以向右滚动,只有空白和汉堡菜单。 也许我忘了加一堂课吗?
答案 0 :(得分:0)
您是否在引用bootstrap js,jquery等?如果没有,请将它们添加到正文的末尾。它是在我这端完成的,还是有效的。
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
它没有任何样式,但是您应该明白了:https://jsfiddle.net/enstL6j7/1/
答案 1 :(得分:0)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg fixed-top text-uppercase bg-inverse" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top"><img style="height: 80px;" src="img/logobanner.png" alt=""></a>
<button class="navbar-toggler navbar-toggler-right text-uppercase bg-primary text-white rounded" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fa fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#page-top">Home</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#about">2</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#portfolio">Foto's</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#portfolio2">Agenda</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-2 px-0 px-lg-3 rounded js-scroll-trigger" href="#contact">Boeken</a>
</li>
</ul>
</div>
</div>
</nav>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
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>
我认为CDN有问题。尽量不要使用jquery slim版本,因为有时它可能会引起问题。