我用HTML和CSS做了一个菜单。它使用链接。它适用于任何设备,但在 768px 时,菜单停止工作,我找不到原因。
谁能帮我?
<nav id="navbar" class="navbar navbar-expand-md navbar-dark fixed-top bg-dark" data-spy="affix" data-offset-top="197">
<h2 style="display:none;">Navegación KSLM</h2>
<a class="klsm" href="#">KSLM</a>
<button class="navbar-toggler" id="#tog" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#inicio">INICIO</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#acercade">ACERCA DE</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#servicios">SERVICIOS</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#ubicacion">UBICACIÓN</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#contacto">CONTACTO</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="https://www.facebook.com/kslmconsultores/?notify_field=blurb&modal=profile_completion¬if_id=1530027180752658¬if_t=page_profile_blurb "></a>
</li>
</ul>
</div>
</nav>
您正在使用"navbar-expand-md"。但是,您想在 Ipad 肖像(768(中显示汉堡菜单,因此请在 lg 屏幕 (992px( 中展开菜单。改用类"navbar-expand-lg">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet" />
<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.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<nav id="navbar" class="navbar navbar-expand-lg navbar-dark fixed-top bg-dark" data-spy="affix" data-offset-top="197">
<h2 style="display:none;">Navegación KSLM</h2>
<a class="klsm" href="#">KSLM</a>
<button class="navbar-toggler" id="#tog" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#inicio">INICIO</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#acercade">ACERCA DE</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#servicios">SERVICIOS</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#ubicacion">UBICACIÓN</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="#contacto">CONTACTO</a>
</li>
<li class="nav-item" data-toggle="collapse" data-target=".navbar-collapse.in">
<a class="nav-link" href="https://www.facebook.com/kslmconsultores/?notify_field=blurb&modal=profile_completion¬if_id=1530027180752658¬if_t=page_profile_blurb "></a>
</li>
</ul>
</div>
</nav>