如何在HTML代码中为按钮添加下拉列表。我使用以下代码生成一个按钮并附上一个下拉列表,但它不起作用。
生成菜单按钮,它甚至在单击时突出显示,但在单击时不显示下拉列表。
.jumbotron {
text-align: center;
color: white;
background-color: black;
height: 120px;
font-size: 50px;
}
body {
background-color: #ededed;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row">
<div class="col-lg-1">
<div class="container">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Menu <span class="glyphicon glyphicon-menu-hamburger"></span></button>
<ul class="dropdown-menu">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
</div>
<div class="col-lg-10">
<div class="container">
<div class="jumbotron container"><strong>FEEDBACK</strong></div>
</div>
</div>
</div>
&#13;
答案 0 :(得分:2)
您必须包含jQuery
库和bootstrap.js
。
为什么你在container
课程中使用col
课程......这不是一个好习惯。
阅读本文: Bootstrap Grid Structure
Stack Snippet
.jumbotron {
text-align: center;
color: white;
background-color: black;
height: 120px;
font-size: 50px;
}
body {
background-color: #ededed;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Menu <span class="glyphicon glyphicon-menu-hamburger"></span></button>
<ul class="dropdown-menu">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div class="container">
<div class="jumbotron container"><strong>FEEDBACK</strong></div>
</div>
&#13;