定位错误
我注意到我正在维护的一个网站在 FF/IE8/Chrome 中存在一些布局错误(位于 此页面) - 左上角的图像有点高,偏离了顶部的标题。
我想知道为什么我在接管该网站时没有注意到它,但我意识到自从我将 IE7 升级到 IE8 后它才变得明显 - 显然这个问题在“正确的”浏览器中早已存在。
对于这些“正确”的浏览器,这个绝对定位的图像需要将 top 属性设置为 59px,而不是 IE7(及更低版本)要求的 56px。
解决方案很简单,但是a)我想首先了解问题,b)我想考虑一系列解决方案(我知道会有不止一个)。 考虑到这一点......
- 问题的原因是什么?
很多定位问题都是由于IE框模型错误造成的,但我认为IE7已经修复了这个问题。 这是一个仍然影响 IE7 的盒子模型问题还是有什么不同?
- 最好的解决方案是什么?
许多消息来源表明,使用条件注释来包含 IE7 补丁 CSS 文件是可行的方法:
<!--[if lte IE 7]>
<link href="IE7Fix.css" rel="stylesheet" type="text/css">
<![endif]-->
简单,但我不想将其插入到网站上每个页面的标题中(但当然我会如果我必须的话)。
我知道有许多 CSS hack 可能可以完成这项工作,但有一种学派认为应该避免使用 CSS,因为它们更难维护,尤其是当新浏览器出现时。 我当然可以理解这种心态; 然而,该网站将在 3 个月内完全重新开发,因此我正在寻找短期解决方案。 如果我选择采用 CSS hack,我需要做什么来更改 IE7 及更低版本的行为?
我还读到,良好的重置样式表可以避免许多此类问题,因此为了一笑,我应用了 Eric Meyer 的 重置 Reloaded 样式表 - 正如预期的那样,它显着破坏了网站。
回顾一下,问题到底是什么? 考虑到问题的短期性质,什么是最佳的长期解决方案?什么解决方案最容易部署?
CSS ('Banner02'): http://new.eminox.com/_lib.css /内容.css
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web
技术交流群。
我注意到我正在维护的一个网站在 FF/IE8/Chrome 中存在一些布局错误(位于 此页面) - 左上角的图像有点高,偏离了顶部的标题。
我想知道为什么我在接管该网站时没有注意到它,但我意识到自从我将 IE7 升级到 IE8 后它才变得明显 - 显然这个问题在“正确的”浏览器中早已存在。
对于这些“正确”的浏览器,这个绝对定位的图像需要将 top 属性设置为 59px,而不是 IE7(及更低版本)要求的 56px。
解决方案很简单,但是a)我想首先了解问题,b)我想考虑一系列解决方案(我知道会有不止一个)。 考虑到这一点......
- 问题的原因是什么?
很多定位问题都是由于IE框模型错误造成的,但我认为IE7已经修复了这个问题。 这是一个仍然影响 IE7 的盒子模型问题还是有什么不同?
- 最好的解决方案是什么?
许多消息来源表明,使用条件注释来包含 IE7 补丁 CSS 文件是可行的方法:
<!--[if lte IE 7]>
<link href="IE7Fix.css" rel="stylesheet" type="text/css">
<![endif]-->
简单,但我不想将其插入到网站上每个页面的标题中(但当然我会如果我必须的话)。
我知道有许多 CSS hack 可能可以完成这项工作,但有一种学派认为应该避免使用 CSS,因为它们更难维护,尤其是当新浏览器出现时。 我当然可以理解这种心态; 然而,该网站将在 3 个月内完全重新开发,因此我正在寻找短期解决方案。 如果我选择采用 CSS hack,我需要做什么来更改 IE7 及更低版本的行为?
我还读到,良好的重置样式表可以避免许多此类问题,因此为了一笑,我应用了 Eric Meyer 的 重置 Reloaded 样式表 - 正如预期的那样,它显着破坏了网站。
回顾一下,问题到底是什么? 考虑到问题的短期性质,什么是最佳的长期解决方案?什么解决方案最容易部署?
CSS ('Banner02'): http://new.eminox.com/_lib.css /内容.css
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,我认为你的问题不在于“banner02”的定位,而是在于“banner01”div 顶部的高度。 我在 FF 和 IE7 中打开该网站,并将页面的顶部边缘对齐。 图像“banner02”的高度位置完全相同,但标题 div“banner01”在一个浏览器中比另一个浏览器更高。 我还认为 IE7 运行在“怪异模式”下,这稍微改变了盒子模型。
为了使 FF 和 IE7 看起来一样(抱歉,我没有安装 IE8,这是我的工作电脑,所以我无法安装太多来检查它们),我做了 2 个更改:
1)
更改 DOCTYPE from:<-- 这可能不是必要的。 请参阅下面的评论。:
2) 定义“banner01”的高度,因为之前没有设置任何高度(在 Global.css 中):(
横幅 02 的高度为 59 像素,因此我们选择 48 的高度,因为 48 + 10px 顶部边框 + 1px 底部边框 = 59px)
这对我来说很清楚......但同样,我只在 2 个浏览器中测试了它。 希望这有帮助!
Actually, I think your problem isnt with the positioning of 'banner02', instead it is with the height of 'banner01' div across the top. I opened the site in FF and IE7 and lined up the top edge of the page. The image 'banner02' is in exactly the same height position, but the header div 'banner01' was taller in one browser than the other. I also think IE7 was running in 'quirks mode' which was slightly changing the box model.
To make FF and IE7 look the same (sorry I dont have IE8 installed, and this is my work PC so I can't go install a much to check them all), I made 2 changes:
1)
change the DOCTYPE from:<-- this probably isn't neccecary. see my comment below.to:
2) define a height for 'banner01', because none was previously set (in Global.css):
(banner 02 is at 59px, so we choose a height of 48 because 48 + 10px top border + 1px bottom border = 59px)
That cleared it up for me... but again, I only tested it in 2 browsers. Hopefully that helps!