DropDown在mvc视图中不起作用

时间:2017-06-21 07:57:10

标签: asp.net-mvc-4

我不知道为什么但是下拉列表是我的mvc视图不起作用,是使用所有引导程序文件,但仍然无法正常工作

            <a href="#" class="dropdown-toggle user-state:active" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Guide <span class="caret"></span></a>
            <ul class="dropdown-menu">
            <li class="dropdown open">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Diamond <b class="caret"></b></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="@Url.Action("GuideView" , "Base" , new { id = 1 })">Carat Weight</a></li>
                    <li><a href="@Url.Action("GuideView" , "Base" , new { id = 2 })">Clarity</a></li>
                </ul>
            </li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Emerald <span class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li><a href="@Url.Action("GuideView" , "Base" , new { id = 3 })">Clarity</a></li>
                    <li><a href="@Url.Action("GuideView" , "Base" , new { id = 4 })">Color</a></li>
                    <li><a href="@Url.Action("GuideView" , "Base" , new { id = 5 })">Cut</a></li>
                </ul>
            </li>
            </ul>

2 个答案:

答案 0 :(得分:0)

我认为你正在尝试创建一个菜单,你的代码看起来很好。我只是尝试创建一个菜单并将代码放在菜单列表下,如下所示,它工作正常。希望这会有所帮助。

maxSize

答案 1 :(得分:0)

这将起作用,看起来像是正确的引导程序。

   <style>
 .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;
            }
    </style 



<div class="container">
    <div class="row">
        <div class="dropdown">
            <a href="#" class="dropdown-toggle" id="dropdownMenu" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">
                Guide
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
                <li class="dropdown-submenu">
                    <a href="#" tabindex="-1">Diamond</a>
                    <ul class="dropdown-menu">
                        <li><a tabindex="-1" href="#">Carat Weight</a></li>
                        <li><a href="#">Clarity</a></li>
                    </ul>
                </li>              
                <li class="divider"></li>
                <li class="dropdown-submenu">
                <a href="#" tabindex="-1">Emerald</a>
                    <ul class="dropdown-menu">
                        <li><a tabindex="-1" href="#">Clarity</a></li>
                        <li><a href="#">Color</a></li>
                        <li><a href="#">Cut</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</div>