我正在使用引导navwalker显示我的菜单。但当我使用时。在下拉链接中,所有元素都将获得标记。(如图所示)
(只有“Jeugd bestuur”和“bestuur”应该是红色的。因为我在那一页。)
这是我的导航:
<nav class="navbar navbar-expand-lg">
<div class="container">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown"
aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars fa-lg"></i>
</button>
<div class="navbar-collapse collapse" id="navbarNavDropdown">
<ul class="navbar-nav nav-fill w-100">
<?php
wp_nav_menu( array(
\'theme_location\' => \'primary\',
\'depth\' => 2,
\'container\' => \'div\',
\'container_class\' => \'collapse navbar-collapse\',
\'container_id\' => \'navbarNavDropdown\',
\'menu_class\' => \'nav\',
\'fallback_cb\' => \'WP_Bootstrap_Navwalker::fallback\',
\'walker\' => new WP_Bootstrap_Navwalker(),
) );
?>
</ul>
</div>
</div>
</nav>
使用这个CSS,我试图获取活动标记
.header ul li.active a {
background-color: #FE0000;
border-radius: 10%;
background:rgba(255, 0, 0, 0.6 );
color: #ffff;
}