1. 程式人生 > >Bootstrap下拉菜單

Bootstrap下拉菜單

htm ref nbsp blank down bind dropdown trap btn

Bootstrap 下拉菜單

<div class="dropdown">
    <button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">主題
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"
> <li role="presentation"> <a role="menuitem" tabindex="-1" href="#">Java</a> </li> <li role="presentation"> <a role="menuitem" tabindex="-1" href="#">數據挖掘</a> </li> <li role="presentation"
> <a role="menuitem" tabindex="-1" href="#">數據通信/網絡</a> </li> <li role="presentation" class="divider"></li> <li role="presentation"> <a role="menuitem" tabindex="-1" href="#">分離的鏈接</a> </li>
</ul> </div>

實現下拉菜單有幾個要點:

  1、根部div必須 class="dropdown"

  2、Button必須 data-toggle="dropdown"

  3、ul必須 class="dropdown-menu"

  技術分享

可以通過js來調用:

$(‘.dropdown-toggle‘).dropdown()

參考:

1、http://www.runoob.com/bootstrap/bootstrap-dropdowns.html

2、http://www.runoob.com/bootstrap/bootstrap-dropdown-plugin.html

Bootstrap下拉菜單