4

I am coding the following in Bootstrap 3.0 and MVC 5. I am trying to get Submenus to work. I referenced navbar documentation but I can't get the Billing and Payment structure to be a sub dropdown menu with this structure:

Account Info
    License Details
    Billing and Payment
       Invoices
       Payments
       Billing
    Users
       User Settings

Here is my HTML. I need to replace the anchor tag on Billing Payment. What do I put in its place?

<div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Free Trial Setup", "Trial", "Home")</li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Account Info</a>
                        <ul class="dropdown-menu">
                            <li>@Html.ActionLink("License Details", "License", "Home" )</li>
                            <li class="dropdown-submenu"></li>
                                <a href="#">Billing and Payment</a>
                                <li>@Html.ActionLink("Invoices", "Invoices", "Home")</li>
                                <li>@Html.ActionLink("Payments", "Payments", "Home")</li>
                                <li>@Html.ActionLink("Billing Information", "Billing", "Home")</li>
                            </ul>
                            <li>User Settings</li>
                        </ul>

                    </li>
                </ul>
                @Html.Partial("_LoginPartial")
            </div>
        </div>
user2471435
  • 1,644
  • 7
  • 35
  • 62
  • 1
    Here's a [jsFiddle](http://jsfiddle.net/2Smgv/2858/) with an example of a nested submenu in BS3. It comes from the Updated answer in this post from [SO](http://stackoverflow.com/questions/9758587/twitter-bootstrap-multilevel-dropdown-menu). Hope that helps. – David Tansey Feb 10 '14 at 16:44
  • I listed the wrong version of Bootstrap -- that example is BS2. – David Tansey Feb 10 '14 at 16:54
  • 1
    There is no dropdown-submenu in BS3. I'll update my code above as I still can't get it working right. – user2471435 Feb 10 '14 at 17:02
  • Have you seen this [post](http://stackoverflow.com/questions/18023493/bootstrap-3-dropdown-sub-menu-missing)? In some ways, not very encouraging -- but a workaround is presented. – David Tansey Feb 10 '14 at 17:05

1 Answers1

0

Based on the solution mentioned in snippet you have to do the following:

  1. Add following to your Site.css file

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

then change your code in the _Layout.cshtml to be:

<div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Free Trial Setup", "Trial", "Home")</li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Account Info</a>
                        <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
                            <li>@Html.ActionLink("License Details", "License", "Home")</li>
                            <li class="dropdown-submenu">
                                <a tabindex="-1" href="#">Billing and Payment</a>
                                <ul class="dropdown-menu">
                                    <li>@Html.ActionLink("Invoices", "Invoices", "Home")</li>
                                    <li>@Html.ActionLink("Payments", "Payments", "Home")</li>
                                    <li>@Html.ActionLink("Billing Information", "Billing", "Home")</li>
                                    <li class="dropdown-submenu">
                                        <a href="#">Users</a>
                                        <ul class="dropdown-menu">
                                            <li><a href="#">User Settings</a></li>
                                        </ul>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                </ul>
                @Html.Partial("_LoginPartial")
            </div>