简体   繁体   English

IE7与Firefox / Opera / Chrome之间的间距差异

[英]Spacing differences between IE7 and Firefox/Opera/Chrome

I have an ongoing issue with the amount of vertical space of unordered lists in IE7 vs. Firefox/Chrome/Opera and I can't seem to find a solution out there. 我在IE7与Firefox / Chrome / Opera中的无序列表的垂直空间数量上存在一个持续的问题,我似乎找不到解决方案。

In IE7, the space is less and what I would like to see. 在IE7中,空间更小,我想看到的空间更少。

In Firefox, Chrome, and Opera, the space between is about twice as much. 在Firefox,Chrome和Opera中,两者之间的距离大约是原来的两倍。

I can't account for any of the spacing issues in my code or page. 我无法解释代码或页面中的任何间距问题。 On my page, the code looks like this: 在我的页面上,代码如下所示:

<!--BEGIN SIDEBOX-->
<div id="sidebox_new">
<div id="sidebox_top"><div id="sup">SUPPORT LINKS</div></div>
<div id="sidebox_bod">
<br />
<ul>
<li><a href="training.aspx">User Training</a></li><br /><br />
<li><a href="faqs.aspx">FAQ</a></li><br /><br />
<li><a href="logonasst.aspx">Logon Assist. Center</a></li><br /><br />
<li><a href="faxus.aspx">Fax Us</a></li><br /><br />
<li><a href="callus.aspx">Call Us</a></li><br /><br />
<li><a href="feedback.aspx">General Feedback</a></li>
</ul>
</div>
<div id="sidebox_btm"></div>
</div>
<!--END SIDEBOX-->

My CSS for this section looks like this: 我的本节CSS如下所示:

#sidebox_bod
{
width: 200px;
margin: 0 30px 0 0;
padding: 0;
background: url('../img/supbxbod.gif');
background-repeat:repeat-y;
background-position:bottom;
}

#sidebox_bod ul
{
list-style-image:url('../triangle.gif'); 
text-align:left;
padding: 0 0 0 30px;
margin: 0;
}

#sidebox_bod ul li a
{
font-size: 13px;
}

Any idea what I can do to try to have the vertical spacing the same across all browsers? 知道如何做才能使所有浏览器的垂直间距相同吗? I would prefer to have the IE7 look to try to fix this. 我希望让IE7能够解决此问题。 Thanks. 谢谢。

The problem you are having right now is due to the fact that each user-agent (Browser) has their own default styles, which may differ from one and the other. 您现在遇到的问题是由于每个用户代理(浏览器)都有自己的默认样式,这种样式可能彼此不同。

Reset stylesheets exists in order to neutralize those styles and achieve a more constant rendering between user-agents. 存在重置样式表是为了中和那些样式并在用户代理之间实现更恒定的呈现。 This will basically remove the issue with all elements. 这基本上将消除所有元素的问题。

In that particular case, playing with margin , padding and line-height of #sidebox_bod ul li will fix your problem: 在这种情况下,使用#sidebox_bod ul li marginpaddingline-height可以解决您的问题:

#sidebox_bod ul { margin: 0; padding: 0 16px; line-height: 1em; }

I would recommend using a Reset CSS though, as that will solve most of those problems for all elements. 但我还是建议您使用Reset CSS,因为这样可以解决所有元素中的大多数问题。

Using break tags in between your list items is not a good idea. 在列表项之间使用分隔符不是一个好主意。 You should be setting specific margin, padding and/or line-height styles for your list item spacing - otherwise it will be unpredictable. 您应为列表项的间距设置特定的边距,填充和/或行高样式-否则将无法预测。

I'd recommend against using 'ems' for measurement if you want exact symmetry, as they are rendered very differently in different browsers and operating systems. 如果您想要精确的对称性,建议不要使用“ ems”进行测量,因为它们在不同的浏览器和操作系统中呈现的方式非常不同。

There are also some white space issues in IE, but usually that would result in more space, rather than less... IE中也存在一些空白问题,但通常会导致更多的空间,而不是更少的...

Regarding the above poster's comment about reset stylesheets - I think it would be better in this instance to set a specific style for your own site. 关于上述张贴者关于重置样式表的评论-我认为在这种情况下最好为您自己的网站设置特定样式。 Reset stylesheets can become largely unnecessary/redundant if you are styling your site at all (ref: http://meiert.com/en/blog/20080419/reset-style-sheets-are-bad/ ) 如果您要对网站进行样式设置,则重置样式表可能在很大程度上变得不必要/多余(请参阅: http : //meiert.com/en/blog/20080419/reset-style-sheets-are-bad/

A link to your site would be great, as its very difficult to debug without seeing the entire CSS file and html context. 链接到您的站点将非常有用,因为在不查看整个CSS文件和html上下文的情况下很难调试。

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

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