简体   繁体   English

Internet Explorer和FireFox之间的CSS顶级属性有所不同

[英]CSS Top Property different between Internet Explorer and FireFox

I've been trying to search for this in stackoverflow but I couldn't find the answer. 我一直在尝试在stackoverflow中搜索它,但是找不到答案。

Browsers I am using for testing: Firefox 3.6.8 Internet Explorer 6.029 我用于测试的浏览器:Firefox 3.6.8 Internet Explorer 6.029

I am creating a box and positioning it via the position:absolute and top and left properties: 我正在创建一个盒子,并通过position:absolute和top和left属性定位它:

#testBox {
  top:10px;
  left:480px;
  width:220px;
  padding:3px;
  position:absolute;
  font-size:14px;
  text-align:center;
}

<div>
  <div>
  <span style="position:relative;">
    <span id="testBox">
    testtesttesttesttest<br />
    </span>
  </span>
</div>

What is happening is the "testBox" span is up further in IE than FireFox. 发生的是,IE中的“ testBox”范围比FireFox更大。 Is there something I can do to fix this problem? 有什么我可以解决的问题吗? Thanks, Roy 谢谢罗伊

Ie6, will be the problem, specifically the 6 part. IE6,将是问题,特别是6部分。

You will most likely need to define different rules in a different style sheet. 您很可能需要在不同的样式表中定义不同的规则。 Look into conditional statements: http://creativebits.org/webdev/ie_conditional_css 查看条件语句: http : //creativebits.org/webdev/ie_conditional_css

Also you can try using a css reset, it will make things easier down the line: http://www.yahooapis.com/yui/3/cssreset/ 另外,您也可以尝试使用CSS重置,这样会使事情变得更简单: http : //www.yahooapis.com/yui/3/cssreset/

I don't know of a non-hackish method, but you can use conditional HTML (ie, a hack) to change top in IE6. 我不知道一种非骇客的方法,但是您可以使用条件HTML(即骇客)来更改IE6的顶部。 Put this after your CSS, in the HTML. 将其放在CSS后面的HTML中。

<!--[if lt IE 7]>
    <style type="text/css">
            #testBox {
               top: 20px; // or whatever
            }
    </style>
<![endif]-->

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

相关问题 为什么我的 css 内容框在 firefox 和 inte.net 资源管理器中大小不同? - why are my css content boxes different sizes in firefox and internet explorer? Firefox和Internet Explorer之间的不同字段集视图问题 - Different fieldset view problem between firefox and internet explorer Internet Explorer和Firefox上缺少CSS - CSS missing on Internet Explorer and Firefox 渐变CSS边框未在Internet Explorer中显示Firefox - Gradient css borders not showing in internet explorer an firefox CSS适用于Internet Explorer,但不适用于Chrome或Firefox - CSS works in Internet Explorer but not Chrome or Firefox 如何在Firefox和Internet Explorer中包含CSS字体? - How to include css font in Firefox and internet explorer? HTMLTabs CSS可在Firefox和Chrome中使用,但不能在Internet Explorer中使用 - HTMLTabs CSS working in firefox and chrome but not in internet explorer Mozilla Firefox和Internet Explorer之间的字体差异 - Font differences between Mozilla Firefox and Internet Explorer Internet Explorer中的background-size css属性 - background-size css property in Internet Explorer 与 Firefox 和 Internet Explorer 不同,Chrome 中不显示顶部横幅图像 - The top banner image not displaying in Chrome unlike in Firefox and Internet Explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM