简体   繁体   English

容器div外部的ASP菜单呈现

[英]ASP Menu rendering outside of it's container div

I'm preparing to demo my client's system, but all my work thus far has been on my development and test environments and has all gone very smoothly. 我正在准备演示客户系统,但到目前为止,我的所有工作都是在开发和测试环境上进行的,一切都进行得很顺利。 Setting the system up on a new environment for the demo has - for some reason I can't explain - wrecked the menu. 为演示安装新环境的系统-由于某种原因,我无法解释-破坏了菜单。

Basically the menu in the demo environment, while using the exact same code as the other, the menu doesn't render inside of it's container. 基本上,菜单是在演示环境中,虽然使用与其他菜单完全相同的代码,但菜单不会其容器呈现。 Screenshots and code to follow: 屏幕截图和代码如下:

How it should look 它应该看起来如何

它应该看起来如何

How it does look 看起来如何

看起来如何

I originally wrote the system in Visual Studio 2012, but due to unforeseen limitations with a demo, I had to "port" it all back to 2010. Basically this just involved some copy/paste of the event handlers and such into new files. 我最初是在Visual Studio 2012中编写该系统的,但是由于演示中的意外限制,我不得不将其全部“移植”到2010年。基本上,这只是涉及事件处理程序的某些复制/粘贴,以及类似的复制到新文件中。

Here's the code: 这是代码:

<div class="menu">
    <asp:Menu runat="server" ID="mnuLoggedIn" Orientation="Horizontal" RenderingMode="List">
        <Items>
            <asp:MenuItem Text="Manage Complexes" NavigateUrl="~/Members/Complex.aspx" ToolTip="View, add, edit or delete complexes"></asp:MenuItem>
            <asp:MenuItem Text="Manage Units" NavigateUrl="Units.aspx" ToolTip="View, add, edit or delete units"></asp:MenuItem>
            <asp:MenuItem Text="Manage Subcontractors" NavigateUrl="Subcontractors.aspx" ToolTip="View, add, edit or delete subcontractors"></asp:MenuItem>
            <asp:MenuItem Text="Manage Insurers" NavigateUrl="Insurers.aspx" ToolTip="View, add, edit or delete insurers"></asp:MenuItem>
            <asp:MenuItem Text="Manage Insurance Policies" NavigateUrl="Policies.aspx" ToolTip="View, add, edit or delete insurance policies"></asp:MenuItem>
            <asp:MenuItem Text="Manage Jobs" NavigateUrl="Jobs.aspx" ToolTip="View, add, edit or delete jobs"></asp:MenuItem>
        </Items>
    </asp:Menu>
</div>

And the css... 还有CSS ...

/* MENU
============================================ */
.menu 
{
    display: block;
    height: 30px;
    clear: both;
    border-radius: 5px 5px 0 0;
    background: #121211;
}
.menu ul li a
{
    margin-left: 20px;
    color: #fff;
    line-height: 30px;
}
.menu ul li a:hover
{
    color: #85bf25;
    border: 0;
}

I feel like maybe I'm relying too much on the asp to handle the menu layout. 我觉得也许我过于依赖asp来处理菜单布局。

I wish I could provide a link to a working test case online, but no hosting that I have access to has support for asp.net. 我希望可以在线提供一个可以正常工作的测试用例的链接,但是没有我可以访问的托管站点支持asp.net。 What I have done is to zip up the master page where this menu is, it's content page (which is as yet empty) and the stylesheet for your attention: 我要做的是压缩该菜单所在的母版页,它的内容页(仍为空)和样式表,以供您注意:

http://www.loganyoung.za.net/code/asp-menu-rendering-outside-of-its-container-div.zip http://www.loganyoung.za.net/code/asp-menu-rendering-outside-of-its-container-div.zip

I've run through this with a fine-toothed comb and I just can't figure out what's causing the menu to appear outside of it's container. 我已经用一把细齿梳梳理了一下,但我不知道是什么原因导致菜单出现在容器的外面。

Any assistance will be greatly appreciated. 任何帮助将不胜感激。 Thanks in advance! 提前致谢!

Still don't know why this happened, but setting a negative top margin put the menu exactly where I needed it: 仍然不知道为什么会这样,但是设置负的上边距会使菜单恰好位于我需要的位置:

.menu 
{
    display: block;
    height: 30px;
    clear: both;
    border-radius: 5px 5px 0 0;
    background: #121211;
}
.menu ul li a
{
    margin-top: -20px;
    margin-left: 20px;
    color: #fff;
    line-height: 30px;
}
.menu ul li a:hover
{
    color: #85bf25;
    border: 0;
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM