简体   繁体   English

IE7尴尬的列表间距

[英]IE7 awkward list spacing

I have a large menu built from lists. 我有一个从列表构建的大菜单。

It is displaying correctly in all the modern browsers I have tried and IE8, however in IE7 the list items appear to be given large amounts of margin of varying size depending on the size of the list item (see image comparison below) : 在我尝试过的所有现代浏览器和IE8中,它都能正确显示,但是在IE7中,列表项似乎具有大量的边距,这些边距取决于列表项的大小(请参见下面的图像比较)

好的浏览器和IE7之间的比较

Unfortunately the debugging tools in IE7 are less than optimal and I am having a real hard time working out where the issue is coming from. 不幸的是,IE7中的调试工具并不是最佳选择,我很难确定问题出在哪里。 The source code is a bit lengthy to post here so I have made a JSfiddle for your viewing pleasure. 源代码在这里发布时有点冗长,所以我制作了一个JSfiddle以便您欣赏。

View source code and working demo 查看源代码和工作演示

Can anyone see where this mystery spacing is coming from, and how can I put it straight? 谁能看到这个神秘的间隔来自何处,我该如何直截了当?

In IE7 the <ul> tags are inheriting a line-height : 1.5em , disabling it in ie7 removes the annoying spacing. 在IE7中, <ul>标签继承了line-height : 1.5em ,在ie7中禁用它会消除烦人的空格。 Updated fiddle 更新的小提琴

This condition is the culprit 这种情况是元凶

ul {
    /* line-height: 1.5em; */
    list-style-position: outside;
}

Additional 额外

Ok I see what you mean about the white gap. 好的,我明白您对空白的意思。 This looks like its (surprise surprise) one of those annoying ie7 'features'. 这看起来像是(令人惊讶的)那些烦人的ie7“功能”之一。 I just got round it by using a hack 我只是通过黑客来解决

ul li, ul li a {
    /* Needed in ie7 to stop list items expanding vertically
    *line-height:1.2em;
}

with

* html ul li a {
    height:15px;
}

or 要么

ul#map > li > a.map-item {
    height:auto;
    *height:15px;
}

Fiddle with no spacing in IE7 IE7中没有空格的小提琴

A better way would be to create an IE7 only stylesheet and declare this as standard rather than relying on a hack. 更好的方法是创建仅IE7的样式表,并将其声明为标准样式,而不是依赖于hack。

Have you tried adding CSS to reset all the styles to the same for all browsers? 您是否尝试过添加CSS以将所有样式重置为所有浏览器相同?

By including a reset CSS file such as: http://meyerweb.com/eric/tools/css/reset/ may help with your issue. 通过包含重置的CSS文件,例如: http : //meyerweb.com/eric/tools/css/reset/,可能会帮助解决您的问题。

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

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