[英]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.