简体   繁体   English

IE7嵌套绝对定位 <ul> 内部相对定位 <ul> 问题

[英]IE7 Nested Absolutely Positioned <ul> Inside Relatively Positioned <ul> Issue

I seem to be running into a strange issue with IE7. 我似乎遇到了IE7的一个奇怪问题。

If you visit the following URL, http://tinyurl.com/3qrbhn4 , and hover over the main navigation at the top, right above the header image in Chrome, Firefox, and IE8, the sub nav that displays once you hover over a nav element (for example, hover over Meetings) appears to line up correctly with the parent LI. 如果您访问以下网址http://tinyurl.com/3qrbhn4 ,然后将鼠标悬停在顶部的主导航栏上,即Chrome,Firefox和IE8中标题图片的正上方,则将鼠标悬停在导航元素(例如,将鼠标悬停在会议上)似乎与父LI正确对齐。 However, if you try hovering over the main nav in IE7, the subnav appears one pixel off. 但是,如果您尝试将鼠标悬停在IE7中的主导航上,则子导航会出现一个像素的偏离。

If you inspect the nested UL, which is #mainNav ul ul, you'll notice that it's being positioned absolutely inside of the parent UL with a left vale of 0. 如果检查嵌套的UL,即#mainNav ul ul,您会注意到它的位置绝对位于父UL内部,其左值为0。

If I give it a left value of left:1px, however, it lines up correctly in IE7, but breaks in Chrome/FF/IE8. 如果我给它一个left:1px的左值,则它在IE7中正确排列,但在Chrome / FF / IE8中损坏。

I'm not sure why this is happening, and I currently have the parent UL (#mainNav ul) positioned relatively, so I'm not sure why there would be a difference in how IE7 displays the subnav UL. 我不确定为什么会发生这种情况,并且当前我将父UL(#mainNav ul)放在相对位置,所以我不确定为什么IE7显示subnav UL的方式会有所不同。 I know I can "fix" this with an IE hack and just force IE7 to display the subnav ul with a left value of 1px, but I'd like to avoid that route if possible. 我知道我可以使用IE hack来“解决”此问题,只是强制IE7以1px的左值显示子导航ul,但我想尽可能避免使用该路由。

Can anyone help? 有人可以帮忙吗? Please let me know if I've provided enough information! 如果我提供了足够的信息,请告诉我! I'm listing the CSS for the nav elements in question: 我列出了有问题的nav元素的CSS:

/* NAVIGATION  *********************************************************************************************** */
     #mainNav { position: relative; width: 951px; margin: 0 auto; padding: 15px 0; z-index: 3; }   

     #mainNav ul { line-height: 100%; height: 35px; margin: 0; padding: 0; font-size: 20px; width: 951px; }
     #mainNav ul li { line-height: 100%; list-style: none; float: left; text-transform: uppercase; height: 100%;  position: relative; display: block; }
     #mainNav ul li a { line-height: 0; height: 22px; border: 1px solid transparent; text-decoration: none; padding: 7px 15px 5px; position:relative; display: block; } 
     #mainNav ul li a:hover {  }
     #mainNav ul li.hover a {  }
     #mainNav ul li a.current {  }
     #mainNav ul li.lastItem {  }

          #mainNav ul ul { display: none; z-index:2;  position: absolute; top: 35px; left: 0px; padding: 5px 0 10px; width: 200px; height: auto; -moz-box-shadow: 3px 3px 3px #444; -moz-box-shadow: 3px 3px 3px rgba(0,0,0,0.5); -webkit-box-shadow: 3px 3px 3px rgba(0,0,0,0.5); }
          #mainNav ul li.current ul { left: 1px; }
          #mainNav ul li.hover ul li { background-position: 10px 8px; background-repeat: no-repeat; }
          #mainNav ul li.hover ul li.hover { background-color: #baceda; background-position: 10px -20px; }
          #mainNav ul li ul li { float: none; }
          #mainNav ul li ul li a { background: none; line-height: 1; font-size: 15px; padding: 3px 30px 0; }
          #mainNav ul li ul li.hover a {  }
          #mainNav ul li ul li a.current {  }

尝试将#mainNav ul ul从left:1px更改为left:auto

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

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