我的导航栏不应用任何样式,甚至不应用默认样式:
Navbar collapsed
Navbar expanded
在头上:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
在身体上:
<body <?php body_class($twichies_classes); ?>
<div class="container-fluid">
<div class="row">
<div class="col-xl-12">
<nav class="navbar navbar-expand-lg navbar-fixed-top navbar-dark danger-color">
<div class="container-fluid">
<div class="navbar-header">
<button class="navbar-toggler" 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>
<a class="navbar-brand" href="#">
My Theme
</a>
</div>
<div class="collapse navbar-collapse" id="navbarNav">
<?php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => false,
'menu_class' => 'nav navbar-nav navbar-right'
)
);
?>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</div><!-- /.container-fluid -->
</nav>
</div>
</div>
</div>
最后:
<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" 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>
已经尝试了其他类别的设置,例如更改为默认值,但仅更改“我的主题”的颜色。似乎wp_nav_menu项使它看起来很奇怪。谢谢你的帮助! :)
最佳答案
当屏幕较小时,单击菜单将显示以下图像。
这是导航栏的图像。
在您的代码中,我已更改
这个
<nav class="navbar navbar-expand-lg navbar-fixed-top navbar-dark danger-color">
至
<nav class="navbar navbar-expand-lg fixed-top navbar-dark danger-color" style="background: #000;">
和这行之后的php代码
<div class="collapse navbar-collapse" id="navbarNav">
至
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
在这里,我这里没有使用任何CSS。
关于php - Navbar没有使用Bootstrap 4的样式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49165202/