Blogger Information
Blog 27
fans 0
comment 0
visits 17910
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
下单菜单-9.26
Yyk.的博客
Original
843 people have browsed it

普通下拉菜单:

实例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../lib/dist/css/bootstrap.css">
    <title>下拉菜单</title>
</head>
<body>


<div class="dropdown"<button type="button" class="btn btn-default" data-toggle="dropdown">
        前端开发 <span class="caret"></span>
    </button>

    <ul class="dropdown-menu">
        <li class="dropdown-header">常用技术</li>
        <li><a href="">HTML5</a></li>
        <li><a href="">CSS3</a></li>
        <li><a href="">JavaScript</a></li>
  
        <li class="divider"></li>
        <li><a href="">jQuery</a></li>
        <li><a href="">Bootstrap</a></li>
    </ul>
</div>


<script src="../lib/jquery.js"></script>
<script src="../lib/dist/js/bootstrap.js"></script>
</body>
</html>

运行实例 »

分裂式菜单:

实例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--1. 导入bootstrap样式文件css;-->
    <link rel="stylesheet" href="../dist/css/bootstrap.css">
	<script src="../jquery.js"></script>
	<script src="../dist/js/bootstrap.js"></script>
    <title>bootstrap导入</title>
</head>
<body>
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-8 col-md-offset-2">
				<h3>分裂式下拉菜单</h3>
				
				<div class="btn-toolbar">
					<div class="btn-group">
						
						<button type="button" class="btn btn-default" data-toggle="dropdown">前端技术</button>
						
						<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
							<span class="caret"></span>
						</button>
						
						<ul class="dropdown-menu">
							<li><a href="">H5</a></li>
							<li><a href="">CSS</a></li>
							<li><a href="">JS</a></li>
							<li class="divider"></li>
							<li><a href="">jQuery</a></li>
							<li><a href="">Bootstrap</a></li>
						</ul>
					</div>
					

				</div>
			

		</div>
		</div>
	</div>
	
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

个人总结:

data-toggle=“dropdown”存在于那个按钮,那么这个按钮就拥有点击显示下拉的功能。比如上面的这个案例,我只在第二个按钮设置了这个属性,那么只能点击三角区域才会显示下拉菜单,点击“前端技术”则不会,而如果在第一个按钮也设置了这个属性,那么第一个按钮,即“前端技术”也就拥有了这个功能了。


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post