我想让dropdown
项目出现在父链接的悬停上,并且可以单击到另一个页面,该怎么做?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-nav" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand navbar-link" href="#"> <img src="assets/img/Saydullogo.png" id="logo"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="app-nav">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="index.php"><span class="fa fa-home"></span> Home</a></li>
<li class="dropdown">
<a href="Categories.php" class="dropdown-toggle" data-toggle="dropdown"><span class="fa fa-medkit"></span> Categories <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Beauty</a></li>
<li><a href="#">Cosmetics</a></li>
<li><a href="#">Medicines</a></li>
</ul>
</li>
<li><a href="#"><span class="fa fa-edit"></span> Registeration</a></li>
<li><a href="#"><span class="fa fa-phone-square"></span> Contact Us</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
最佳答案
将此CSS放入您的代码中
.dropdown:hover .dropdown-menu {
display: block !important;
}
查看您的代码段
.dropdown:hover .dropdown-menu {
display: block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-nav" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand navbar-link" href="#"> <img src="assets/img/Saydullogo.png" id="logo"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="app-nav">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="index.php"><span class="fa fa-home"></span> Home</a></li>
<li class="dropdown">
<a href="Categories.php" class="dropdown-toggle" ><span class="fa fa-medkit"></span> Categories <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Beauty</a></li>
<li><a href="#">Cosmetics</a></li>
<li><a href="#">Medicines</a></li>
</ul>
</li>
<li><a href="#"><span class="fa fa-edit"></span> Registeration</a></li>
<li><a href="#"><span class="fa fa-phone-square"></span> Contact Us</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
关于javascript - 如何使下 zipper 接的标题在导航栏中可单击,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44042906/