<li><a href="#" class=" dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">CONTACT<span class="caret"></span></a>
</li>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
</ul>
有人可以帮助我。一切都来自bootstrap的网站。继承人整个html文件 http://pastebin.com/YXsVPRhz
答案 0 :(得分:1)
您错过了data-target
中的a.dropdown-toggle
,以及目标id
的{{1}}。
对于ul
,添加一个数据目标属性,该属性是a
的id:
ul
对于data-toggle="dropdown" //sample name
,请添加ID:
ul
所以它应该是:
id="dropdown" //sample name
答案 1 :(得分:0)
添加ul
作为锚点的兄弟
<li>
<a href="#" class=" dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">CONTACT<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a>
</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a>
</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a>
</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a>
</li>
</ul>
</li>
演示:Fiddle