Firefox vs IE中的CSS边距问题 [英] CSS margin problems in Firefox vs IE

查看:66
本文介绍了Firefox vs IE中的CSS边距问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个div,div里面是一个标题和一个表。 我希望表格从标题的底部开始说是50px。所以我给表格一个margin-top50px。在FF中,它计算表格与标题的边距,在IE中它计算与div顶部的边距,参见附图。

你能解释或指导我解决Firefox和IE中的边距有什么问题。

我已经阅读了关于在这里折叠边距的文章(19.5 KB,518 views)

解决方案

在标记中,您是否明确设置了相对性?即使有标准,我也遇到了浏览器不具备相同默认值的问题。说到CSS。如果设置相对论并没有解决问题,请告诉我们,我们将一起解决这个问题。


还有一件事,你使用的是什么版本的浏览器?在解决跨浏览器问题时,这可以提供相当多的帮助。


- - - - - -

- 编辑 -

- - - - - -

重新阅读你的帖子后,我意识到你实际上在问什么。傻傻的我,我不应该迟到。 ;)


虽然我上面发布的内容确实有答案,但它并没有明确解释。正如我所提到的,每个浏览器都有自己的处理方式,这包括CSS的默认值。几乎所有做过任何网页设计并尝试使其跨浏览器兼容的人都会告诉你,IE是打破CSS的罪魁祸首。


至于你的问题是什么有,你总是可以添加浏览器特定的标记。但是,有些人认为这是作弊行为。应该总是有一种解决方法(关键词:假设)使用纯CSS。


我不明白你对相对论的意思。你能解释一下吗?我还在学习。


对此我很抱歉,我不应该假设。 :)我使用了术语相对论。就像div的定位一样。 position:relative | absolute | etc它只是layouts / divs / etc的定位CSS规则。


更多信息: W3C


Hi people, I have a div, inside the div is a heading and a table. I want the table to be say 50px from the bottom of the heading. So I give the table a margin-top50px. In FF it calculates the table''s margin against the heading and in IE it calculates the margin against the top of the div, see attached image.
Could you please explain or guide me to what the problem is with the margins in Firefox and IE.
I''ve read the article on collapsing margins here http://complexspiral.com/publication...psing-margins/ but its still not working for me.

Attached Images
Untitled.jpg (19.5 KB, 518 views)

解决方案

In the markup, are you setting the relativity explicitly? Even though there are standards, I''ve run across issues with browsers not having the same "defaults" when it comes to CSS. If setting the relativity doesn''t fix the problem, let us know and we''ll figure this out together :)

One more thing, what versions of said browsers are you using? This can help out quite a bit when troubleshooting cross-browser issues.

- - - - - -
- EDIT -
- - - - - -
After re-reading your post again, I realized what you were actually asking. Silly me, I shouldn''t be up this late. ;)

Although what I posted above does have merit in the answer, it doesn''t explain is clearly. As I mentioned, every browser has it''s own way of doing things and this includes defaults for CSS. Just about anyone who has done any webdesign and tried to make it cross-browser compatible will tell you that IE is a big culprit for breaking CSS.

As far as the issue goes that you''re having, you could always add a browser specific markup. However, some believe this is cheating. There is supposed to always be a way around it (keyword: supposed) using pure CSS.


Hi, I do not understand what you mean with the "relativity". Could you explain that to me. I''m still learning.


Sorry about that, I shouldn''t be assuming. :) I used the term "relativity" as in the positioning of the div. position: relative|absolute|etc It''s just a positioning CSS rule for layouts/divs/etc.

For more info: W3C


这篇关于Firefox vs IE中的CSS边距问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆