MVC Umbraco站点bootstrap navbar奇怪的行为

时间:2016-02-26 20:05:54

标签: asp.net-mvc twitter-bootstrap umbraco

我有一个Umbraco网站,我正在使用bootstrap,当我拉动导航并尝试使用下拉列表将其格式化为最终导航元素" NEWS"直接放在启用了下拉列表的EVENTS下面。我无法弄清楚造成这种情况的原因。这是呈现的HTML和查看代码

HTML

 <nav class="navbar navbar-fixed-top navbar-header-full" id="header">

    <div class="header-full-title">
        <img src="/Content/img/MTC_logo_header.png" />
    </div>
    <div class="top-nav" style="border: 2px dashed white;">



                    <a href="" ng-click="goToAnchor(1120)" class="navStyle"><span class="navStyle">OUR STORY</span></a> <span class="navStyle">&nbsp;|</span>
                    <a href="" ng-click="goToAnchor(1121)" class="navStyle"><span class="navStyle">VISIT</span></a> <span class="navStyle">&nbsp;|</span>
                    <a href="" ng-click="goToAnchor(1122)" class="navStyle"><span class="navStyle">DIRECTORY</span></a> <span class="navStyle">&nbsp;|</span>
                    <a href="" ng-click="goToAnchor(1123)" class="navStyle"><span class="navStyle">CONDOS</span></a> <span class="navStyle">&nbsp;|</span>
                    <a href="" ng-click="goToAnchor(1124)" class="navStyle"><span class="navStyle">APARTMENT</span></a> <span class="navStyle">&nbsp;|</span>
                    <ul class="dropdown">
                        <a href="#" class="navStyle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">EVENTS</a><span class="navStyle">&nbsp;|</span>
                        <ul class="dropdown-menu dropDownMTC">
                            <li><a href="#">YOGA ROCKS THE PARK</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">MONDAY NIGHT MOVIES</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">HORSES OF HONOR</a></li>
                            <li role="separator" class="divider"></li>


                            <li><a href="#">THURSDAY IN THE PARK</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">EVENT SHUTTLE</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">HOLIDAY LIGHTS FESTIVAL</a></li>
                        </ul>
                    </ul>
                    <a href="" ng-click="goToAnchor(1128)" class="navStyle"><span class="navStyle">NEWS</span></a> <span class="navStyle"></span>


  </div>

    </nav>

查看代码

 <nav class="navbar navbar-fixed-top navbar-header-full" id="header">

    <div class="header-full-title">
        <img src="~/Content/img/MTC_logo_header.png" />
    </div>
    <div class="top-nav" style="border: 2px dashed white;">



            @foreach (var child in Model.Content.Children)
            {
                var isFirstAttribute = child.IsFirst() ? "cn-first" : "";
                var isLastAttribute = child.IsLast() ? "" : "&nbsp;|";



                if (child.GetPropertyValue("navigationTitle").ToString() == "EVENTS")
                {

                    <ul class="dropdown">
                        <a href="#" class="navStyle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">EVENTS</a><span class="navStyle">@Html.Raw(@isLastAttribute)</span>
                        <ul class="dropdown-menu dropDownMTC">
                            <li><a href="#">YOGA ROCKS THE PARK</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">MONDAY NIGHT MOVIES</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">HORSES OF HONOR</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">THURSDAY IN THE PARK</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">EVENT SHUTTLE</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">HOLIDAY LIGHTS FESTIVAL</a></li>
                        </ul>
                    </ul>


                }

                else
                {

                    <a href="" ng-click="goToAnchor(@child.Id)" class="navStyle"><span class="navStyle">@Html.Raw(child.GetPropertyValue("navigationTitle"))</span></a> <span class="navStyle">@Html.Raw(@isLastAttribute)</span>

                }

            }




    </div>

    </nav>

在李的打包后编辑屏幕照片

nav

1 个答案:

答案 0 :(得分:0)

我非常确定您的每个导航栏链接元素都应该位于<li>中,而不仅仅是<a href="...">个链接列表。

请参阅bootstrap docs

中的示例标记
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  <ul class="nav navbar-nav">
    <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
    <li><a href="#">Link</a></li>
    <li class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><a href="#">Action</a></li>
        <li><a href="#">Another action</a></li>
        <li><a href="#">Something else here</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">Separated link</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">One more separated link</a></li>
      </ul>
    </li>
  </ul>