3

我正在使用Twitter Bootstrap 拆分按钮下拉菜单。当它悬停而不是单击箭头时,如何让它下拉?

这与上一个问题类似,但针对不同的 Twitter Bootstrap 元素。

4

2 回答 2

4

The solution to this is nearly the same as the question in your link. You need to add some CSS to the :hover pseudo selector that will display the dropdown. The hovered element must encompass both the button, and the dropdown list. In the example below, I added the btn-hover class to the button group to act as my hover selector.

        <div class="btn-group btn-hover">
          <button class="btn dropdown-toggle" data-toggle="dropdown" href="#">
            Action
            <span class="caret"></span>
          </button>
          <ul class="dropdown-menu">
            <li><a href="#">Test</a></li><!-- dropdown menu links -->
            <li><a href="#">Test 2</a></li><!-- dropdown menu links -->
          </ul>
        </div>

CSS:

div.btn-group:hover ul.dropdown-menu{
    display: block;    
}

div.btn-group ul.dropdown-menu{
    margin-top: 0px;    
}
于 2012-05-27T21:06:17.273 回答
0

将此代码用于更大的设备悬停效果和更小的设备点击效果:

$(document).ready(function(){

  $('.dropdown').append("<style type='text/css'>@media screen and (min-width: 768px) { .dropdown:hover .dropdown-menu {display: block;} }</style>"); 

});
于 2014-12-12T10:01:02.130 回答