简体   繁体   English

菜单在IE中的行为有所不同

[英]Menu behaves differently in IE

I'm working on a site that works as expected in Chrome but opening it in Internet Explorer a see that the navigation menu is out of place. 我正在一个可以在Chrome上正常工作的网站上,但是在Internet Explorer中打开它却发现导航菜单不正确。

Investigating the problem a saw that not all the list items are wrapped inside the main ul and 2 list items do not have the correct class. 研究此问题后,发现并非所有列表项都包装在主ul中,并且2个列表项没有正确的类。

The one with the problem: 有问题的一个:

在此处输入图片说明

The correct one: 正确的:

在此处输入图片说明

My project is made using ASP.NET MVC 4 and Umbraco CMS. 我的项目是使用ASP.NET MVC 4和Umbraco CMS制作的。 The menu View looks like this: 菜单视图如下所示:

<ul class="nav">
<li class="@(CurrentPage.Url == "/" ? "current_page_item" : null)"><a class="Lvl1 home" href="/">Home</a></li>

@foreach (var item in menuItems)
{
<li class="@(CurrentPage.Id == item.Id ? "current_page_item" : null) Col1">
    <a class="lvl1 parent" href="@item.Url">@item.Name</a>

    @{ var subMenuItems = item.Children.Where("Visible"); }

    @if (subMenuItems.Count() > 0)
    {
        <ul>
            <li>
            @foreach (var sub in subMenuItems)
            {
                if (sub.HasValue("menuItemImage"))
                {
                    <div class="NavItemHolder">
                        <div class="NavItemImage">
                            <a href="@sub.Url"><img src="@Umbraco.Field(sub, "menuItemImage", recursive: true)"></a>
                        </div>
                        <div class="NavItemDesc">
                            <a href="@sub.Url">
                            <span>@sub.Name</span><br>
                            <span>@sub.menuItemInfo</span>
                            </a>
                        </div>
                    </div>
                }
                else
                {<li><a class="parent" href="@sub.Url">@sub.Name</a></li>}
            }
            </li>
        </ul>
    }
</li>
}
</ul>

This works fine in Chrome, and cant seem to find the problem for IE. 这在Chrome中正常运行,似乎无法找到IE的问题。

You should have a new list item for each submenu rather than wrapping all the submenus in one list item (or otherwise nesting list items without separating them into proper nested lists with a ul wrapper). 您应该为每个子菜单都有一个新的列表项,而不是将所有子菜单都包装在一个列表项中(或者嵌套列表项,而不用ul包装器将它们分成适当的嵌套列表)。

<ul class="nav">
<li class="@(CurrentPage.Url == "/" ? "current_page_item" : null)"><a class="Lvl1 home" href="/">Home</a></li>

@foreach (var item in menuItems)
{
<li class="@(CurrentPage.Id == item.Id ? "current_page_item" : null) Col1">
    <a class="lvl1 parent" href="@item.Url">@item.Name</a>

    @{ var subMenuItems = item.Children.Where("Visible"); }

    @if (subMenuItems.Count() > 0)
    {
        <ul>
            @foreach (var sub in subMenuItems)
            {
                <li>
                if (sub.HasValue("menuItemImage"))
                {
                    <div class="NavItemHolder">
                        <div class="NavItemImage">
                            <a href="@sub.Url"><img src="@Umbraco.Field(sub, "menuItemImage", recursive: true)"></a>
                        </div>
                        <div class="NavItemDesc">
                            <a href="@sub.Url">
                            <span>@sub.Name</span><br>
                            <span>@sub.menuItemInfo</span>
                            </a>
                        </div>
                    </div>
                }
                else
                {<a class="parent" href="@sub.Url">@sub.Name</a>}
                </li>
            }
        </ul>
    }
</li>
}
</ul>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery选择器在IE中的行为有所不同 - jQuery selector behaves differently in IE getElementsByTagName()在IE和FF中的行为有所不同 - getElementsByTagName() behaves differently in IE and FF jQuery字符串比较在IE7中的行为有所不同 - jQuery string comparison behaves differently in IE7 JavaScript替换在Chrome和IE中的行为有所不同 - JavaScript replace behaves differently in Chrome to IE Javascript日期构造函数在IE和Chrome中的行为有所不同 - Javascript Date constructor behaves differently in IE and Chrome jQuery Dropdown菜单在IE和Webkit中的行为有所不同 - jQuery Dropdown menu behaves different in IE and Webkit 当开发者工具打开 IE11 时,网站的行为会有所不同 - Site behaves differently when developer tools are open IE11 jQuery的点击行为有所不同 - jQuery on click behaves differently OpenLayers 3 Rotation示例在Win32触摸设备上的IE / Chrome嵌入式WebBrowser控件中的行为有所不同 - OpenLayers 3 Rotation example behaves differently in IE/Chrome embedded WebBrowser control on Win32 touch device 更改location.hash,然后按“后退”按钮-IE的行为与其他浏览器不同 - Change location.hash and then press Back button - IE behaves differently from other browsers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM