css - IE7 ul显示:none/block problem

标签 css list mootools internet-explorer-7

我在使用 IE7 时遇到了一个奇怪的问题。 这是我的 html:

          <div class="nav square">
            <div>
              <ul>
                <li><a href="#square" class="square_lk">[b] square</a></li>
                <li><a href="#history" class="history_lk">[b] history</a></li>
              </ul>
            </div>
          </div>

这是我的 CSS:

.nav ul { 
position: absolute; margin-top: -50px; top: 0; left: 0; width: 100px; font-size: 10px !important; background-color: rgb(159,55,32); 
display: none;}

and finally this is my MooTools:

var nav_divs = $$('.nav div');<p></p>

<p>for(i=0; i

</p><pre><code> nav_divs[i].onmouseover = function () {
     this.getElementsByTagName('ul')[0].style.display = 'block';
}
nav_divs[i].onmouseout = function () {
     this.getElementsByTagName('ul')[0].style.display = 'none';
}
</code></pre>

<p>}
</p>
在 Firefox、Opera、Safari Chrome 和 IE8 中一切正常,但在 IE7 中,当我在 div 上时,ul 不显示。

我也尝试过使用简单的 jQuery 函数,但 IE7 中的错误仍然存​​在。

提前感谢您的任何建议。

最佳答案

我同意,这不是冒泡问题,它很可能与您应用到 ul 的 CSS 有关。

top: 0left: 0,是否意味着在绝对元素上执行此操作?不知道,除非 ul 必须播种在视口(viewport)的左上角(然后 -50px 通过上面的 margin-top 会使它超出可视区域)。

http://www.jsfiddle.net/uAAge/

通过从 css 类中删除 top:left: 声明,它可以作为相对弹出窗口(在 ie7、ff3 和 chrome 中测试)。如果您现在需要偏移它以便它更好地定位在触发元素周围,请改用 marginTop 和 marginLeft。

关于css - IE7 ul显示:none/block problem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3143646/

相关文章:

javascript - 重复交通灯序列

javascript - 使用 jquery/CSS 的预期效果

java - 如何在 java 中列出一个 tar 文件的所有条目?

python - 如何在python中查找列表的序列号(如行号1、2)

C# 列表,在*最后一个非空元素之后删除所有空值

javascript - 预加载 CSS 文件中定义的图像

javascript - 每个 mootools "this"?

html - ul li 具体定位

javascript - 当我检查元素时,如何使用 Javascript 设置输入值,不仅用于 View ,还用于元素中的永久值?

css - 在 100% 宽度背景内居中并为内容提供固定宽度的最佳方法是什么?