网站上的 HTML 跨浏览器问题
通常我可以自己修复 HTML 错误,因为它并不那么复杂,但这一次,我遇到了困难。
我决定更改网站上的导航,其中大部分都运行良好且易于使用。大多数浏览器都能正确显示它。
我的问题是,我有 5-6 像素的边距,但我找不到它的来源。链接&显示我的问题的图片如下。
我的第二个问题是 IE7 显示出巨大的余量,而且我也无法找出它的来源。
网页网址为:Deaglegame.net &下面是图片:
我要去工作几个小时,所以如果我没有回复,并不是因为我不想回复,我会尽快检查此线程,但非常感谢任何帮助!
感谢任何愿意提供帮助的人!
Normally I'm able to fix my HTML errors by myself since it's not that complicated, but this time, I'm having a hard one.
I decided to change my navigation on my website and most of it works well & most browsers displays it correctly.
Where my problem is tho, is that I have a 5-6px margin I cannot find where is coming from. The link & image showing my problem will be below.
My second problem is that IE7 shows a huge margin, and again, I cant spot where it's coming from.
The webpage URL is: Deaglegame.net & below here is the image:
I'm leaving for work in a couple hours, so if I dont reply it's not because I dont wanna reply, I'll check this thread as soon as possible, but any help is greatly appreciated!
Thanks to anyone willing to help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
IE7 问题是由于兼容性视图造成的。如果您通过 Intranet 地址访问该页面,则默认情况下会强制执行此操作。您可以通过删除主 div 的底部填充并将高度设置为 175px 来解决此问题。这似乎也解决了运行兼容性视图时的边距问题。
您的菜单项列表以某种方式导致兼容性视图之外的边距问题,我建议在运行 IE 时按 F12,这应该打开开发人员工具,这就是我发现这些需要调整的设置的方式。
The IE7 Issue is due to compatibility view. This will be forced on you by default if you are visiting the page through an intranet address. You can get around this issue by dropping the bottom padding and setting the height to 175px: for the main div. This also seems to fix the margin issue when running compatibility view.
You menu item list is somehow causing the margin issue outside of compatibility view, I would suggest when running IE to hit F12 and that should open Developer tools, that is how I found these settings that needed to be adjusted.
@Mmerrell 对
div#main
的修复应该可以解决问题的一半。接下来是 @Bumble Bee 对ul#navigation li a span
样式的观察。SPAN
元素的填充导致您的链接推送内容。将填充放在它们上并设置
line-height
属性。一般来说,最好使用line-height
来代替padding
来进行文本的垂直定位(它适用于块元素和内联元素的内容)。@Mmerrell's fix for
div#main
should sort one half of the issue. Next comes @Bumble Bee's observation for yourul#navigation li a span
styles. The padding of theSPAN
elements is causing your links to push the content.Drop the padding on them and set the
line-height
property. In general, it's better to useline-height
for the vertical positioning of text (it applies to content of both block and inline elements) in place ofpadding
.您将来可能需要考虑使用 YUI CSS 重置(或者甚至现在集成它),http ://developer.yahoo.com/yui/3/cssreset/。我发现它在设计跨浏览器兼容网站时对我有很大帮助,并且几乎消除了我遇到的奇怪的边距或填充错误。
You may want to consider using YUI CSS reset in the future (or perhaps even integrating it now), http://developer.yahoo.com/yui/3/cssreset/ . I've found it helps me considerably when designing cross-browser compatible sites, and has almost eliminated weird margin or padding errors I come across.
检查下图,这可能会解决您的第一个问题。尝试为那里的填充指定较小的值。考虑使用 firebug 等工具来解决此类问题。
Check the image below, which might solve your first problem. Try to specify a lesser value for the padding there. Consider using a tool like firebug to resolve this kind of issues.