无论是否将dropdown-toggle引导类应用于<button>元素,下拉菜单都可以完美地工作,那么为什么要首先使用它呢?
dropdown-toggle
<button>
clj7thdc1#
dropdown-toggle类将:focus上的outline: 0;添加到按钮中,因此当您单击按钮时,它周围将没有“活动”元素的蓝色边框。检查下两瓶:
:focus
outline: 0;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <div class="container"> <h2>Dropdowns</h2> <p>The .divider class is used to separate links inside the dropdown menu with a thin horizontal line:</p> <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Tutorials - no border <span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> <li class="divider"></li> <li><a href="#">About Us</a></li> </ul> </div> </div> <div class="container"> <h2>Dropdowns</h2> <p>The .divider class is used to separate links inside the dropdown menu with a thin horizontal line:</p> <div class="dropdown"> <button class="btn btn-default" type="button" data-toggle="dropdown">Tutorials - with border <span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> <li class="divider"></li> <li><a href="#">About Us</a></li> </ul> </div> </div>
koaltpgm2#
它添加了以下CSS属性,但它们会影响下拉按钮内容的显示时间:
指令集它基本上是一些button内在box-shadow时的.open,以及color,background-color,border-color和outline(在:focus上)的清除.这里比较一下两者:
button
box-shadow
.open
color
background-color
border-color
outline
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <!-- Single button --> <div class="btn-group"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> With .dropdown-toggle <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="#">Action</a> </li> <li><a href="#">Another action</a> </li> <li><a href="#">Something else here</a> </li> <li role="separator" class="divider"></li> <li><a href="#">Separated link</a> </li> </ul> </div> <!-- Single button --> <div class="btn-group"> <button type="button" class="btn btn-default" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Without .dropdown-toggle <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="#">Action</a> </li> <li><a href="#">Another action</a> </li> <li><a href="#">Something else here</a> </li> <li role="separator" class="divider"></li> <li><a href="#">Separated link</a> </li> </ul> </div>
在Chrome、Opera和Safari中测试的差异:
指令集
kt06eoxx3#
<div class="dropdown-menu dropdown-menu-right mailbox scale-up"> <ul> <li> <div class="drop-title">Pedidos preparados</div> </li> <li> <div><p>hola</p></div> </li> </ul> </div>
3条答案
按热度按时间clj7thdc1#
dropdown-toggle
类将:focus
上的outline: 0;
添加到按钮中,因此当您单击按钮时,它周围将没有“活动”元素的蓝色边框。检查下两瓶:
koaltpgm2#
它添加了以下CSS属性,但它们会影响下拉按钮内容的显示时间:
指令集
它基本上是一些
button
内在box-shadow
时的.open
,以及color
,background-color
,border-color
和outline
(在:focus
上)的清除.这里比较一下两者:在Chrome、Opera和Safari中测试的差异:
指令集
kt06eoxx3#