示例 2 : 标题不可点击 示例 3 : 分割线 示例 4 : 禁用项
菜单div
<div class="dropdown"> 下拉按钮,id用来给下拉菜单指向用的 <button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown"> 菜单列表,aria-labelledby="dropdownMenu1" 就是用来指向哪个菜单,因为有可能有多个菜单 <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> 菜单项 <li><a href="#">HTML</a></li> <!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="dropdown">
<button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">
http://192.168.1.189
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li>
<a href="#">HTML</a>
</li>
<li role="presentation">
<a href="#">CSS</a>
</li>
<li role="presentation">
<a href="#">Javascript</a>
</li>
<li role="presentation">
<a href="#">AJAX</a>
</li>
</ul>
</div>
<div style="height:100px"></div>
标题不可点击
<li role="presentation" class="dropdown-header">Dropdown header</li> <!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="dropdown">
<button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">
http://192.168.1.189
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li class="dropdown-header">
静态页面(不可点击)
</li>
<li>
<a href="#">HTML</a>
</li>
<li role="presentation">
<a href="#">CSS</a>
</li>
<li class="dropdown-header">
动态页面(不可点击)
</li>
<li role="presentation">
<a href="#">Javascript</a>
</li>
<li role="presentation">
<a href="#">AJAX</a>
</li>
</ul>
</div>
<div style="height:100px"></div>
菜单分割线
<li role="presentation" class="divider"></li> <!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="dropdown">
<button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">
http://192.168.1.189
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li class="dropdown-header">
静态页面
</li>
<li>
<a href="#">HTML</a>
</li>
<li role="presentation">
<a href="#">CSS</a>
</li>
<li role="presentation" class="divider"></li>
<li class="dropdown-header">
动态页面
</li>
<li role="presentation">
<a href="#">Javascript</a>
</li>
<li role="presentation">
<a href="#">AJAX</a>
</li>
</ul>
</div>
<div style="height:100px"></div>
禁用的菜单项
<li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Bootstrap(开发中)</a></li> <!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="dropdown">
<button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">
http://192.168.1.189
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li class="dropdown-header">
静态页面
</li>
<li>
<a href="#">HTML</a>
</li>
<li role="presentation">
<a href="#">CSS</a>
</li>
<li role="presentation" class="divider"></li>
<li class="dropdown-header">
动态页面
</li>
<li role="presentation">
<a href="#">Javascript</a>
</li>
<li role="presentation">
<a href="#">AJAX</a>
</li>
<li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Bootstrap(开发中)</a></li>
</ul>
</div>
<div style="height:200px"></div>
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
问答区域
2021-01-24
在使用Bootstrap的下拉菜单时,如何将菜单的选择结果传出?
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2020-10-29
弹不出来的原因
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2020-10-10
关于role和tabindex
2020-08-05
<li role="presentation"> role="menuitem"这些什么意思
2020-03-12
下拉点击无反应
提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 13 条以前的提问,请 点击查看
提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|