twitter-bootstrap bootstrap 上的下拉子菜单不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31236520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 22:54:17  来源:igfitidea点击:

Dropdown submenu on bootstrap is not working

javascripthtmlcsstwitter-bootstrapdrop-down-menu

提问by Niel Sinel

I just wanna ask why is it the dropdown submenu on bootstrap is not working, i just followed the instructions in this link: (http://getbootstrap.com/2.3.2/components.html) but still the dropdown sub menu on a submenu did not appear. By the way I did not change or override classes in the CSS.

我只是想问为什么引导程序上的下拉子菜单不起作用,我只是按照此链接中的说明操作:(http://getbootstrap.com/2.3.2/components.html)但仍然是下拉子菜单上的子菜单没有出现。顺便说一下,我没有更改或覆盖 CSS 中的类。

Here's my code! :)

这是我的代码!:)

<li class='dropdown'><a class='dropdown-toggle active' data-toggle='dropdown' href='#'><img src = 'images/forbank.png' height = 35 width = 35>Banking<span class='caret'></span></a>
                <ul class='dropdown-menu'>
                    <li class = 'dropdown-submenu'><a tabindex='-1' href='#'><span class = 'glyphicon glyphicon-cog'> </span>  Transaction</a>
                        <ul class='dropdown-menu' role = 'menu'>
                            <li><a tabindex='-1' href='#'> Withdrawal / Deposit </a></li>
                            <li><a tabindex='-1' href='#'> Fixed Deposit </a></li>
                        </ul>
                    </li>
                    <li role='separator' class='divider'></li>
                    <li><a href='#'><span class='glyphicon glyphicon-list-alt'> </span> Summaries </a></li>
                    <li><a href='#'><span class='glyphicon glyphicon-wrench'> </span>  Settings </a></li>
                </ul>
            </li>

回答by Dominick Navarro

Please verify if your the instructions you have followed corresponds to your bootstrap version.

请验证您遵循的说明是否与您的引导程序版本相对应。

Additionally, you can try to include this few lines of CSS to make things work.

此外,您可以尝试包含这几行 CSS 以使其正常工作。

.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -6px;
    margin-left: -1px;
    -webkit-border-radius: 0 6px 6px 6px;
    -moz-border-radius: 0 6px 6px;
    border-radius: 0 6px 6px 6px;
}

.dropdown-submenu:hover>.dropdown-menu {
    display: block;
}

.dropdown-submenu>a:after {
    display: block;
    content: " ";
    float: right;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #ccc;
    margin-top: 5px;
    margin-right: -10px;
}

.dropdown-submenu:hover>a:after {
    border-left-color: #fff;
}

.dropdown-submenu.pull-left {
    float: none;
}

.dropdown-submenu.pull-left>.dropdown-menu {
    left: -100%;
    margin-left: 10px;
    -webkit-border-radius: 6px 0 6px 6px;
    -moz-border-radius: 6px 0 6px 6px;
    border-radius: 6px 0 6px 6px;
}

回答by Niel Sinel

I did it, but the problem is the the submenu for "Withdrawal/Deposit" and "Fixed Deposit" is blocking the parent submenu "Transaction", it does not go to the right of it during hover. Here is my code now.

我做到了,但问题是“提款/存款”和“固定存款”的子菜单阻止了父子菜单“交易”,它在悬停期间不会移动到它的右侧。这是我的代码。

        <li class='dropdown'><a id = 'dLabel' class='dropdown-toggle active' data-toggle='dropdown' href='#'><img src = 'images/forbank.png' height = 35 width = 35>Banking<span class='caret'></span></a>
            <ul class='dropdown-menu multi-level' role='menu' aria-labelledby='dropdownMenu'>
                <li class = 'dropdown-submenu'>
                <a  tabindex = '-1' href='#'><span class = 'glyphicon glyphicon-cog'> </span>  Transaction </a>
                    <ul class='dropdown-menu'>
                        <li><a tabindex='-1' href='#'> Withdrawal / Deposit </a></li>
                        <li><a tabindex='-1' href='#'> Fixed Deposit </a></li>
                    </ul>
                </li>
                <li role='separator' class='divider'></li>
                <li><a href='#'><span class='glyphicon glyphicon-list-alt'> </span> Summaries </a></li>
                <li><a href='#'><span class='glyphicon glyphicon-wrench'> </span>  Settings </a></li>
            </ul>
        </li>