Html IE 位置问题:绝对

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7499538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:42:39  来源:igfitidea点击:

Problem with IE position: absolute

htmlcss

提问by Julie

I have this code it works quite well in Firefox; but shoots to the right on Explorer. Is there anything wrong with this code that I can't see?

我有这段代码,它在 Firefox 中运行良好;但是在资源管理器上向右射击。这段代码有什么问题我看不到吗?

Your help is appreciated

感谢您的帮助

<div style="position: absolute; top: 170px"><a href="http://www.mysite.com"><img src="images/sponsor.png" /></a></div>

What I'm expecting is for the image to show on top of the main header image- which works alright on Firefox, but moves to the far right in IE causing the site to break. Not sure why this is happening.

我期望图像显示在主标题图像的顶部 - 这在 Firefox 上工作正常,但在 IE 中移动到最右侧导致站点中断。不知道为什么会这样。

回答by Shadow Wizard is Ear For You

Add left: 0px;as well, IE probably won't give it such default value:

添加left: 0px;为好,IE浏览器可能不会给它这样的默认值:

<div style="position: absolute; top: 170px; left: 0px;">

回答by Ionut Sultana

I found out that IE won't recognize properties declared like :

我发现 IE 无法识别如下声明的属性:

top:(space)20px;

- so if you have a space between :and 20pxIE will ignore that property. I hope this helps someone.

- 所以如果你:20pxIE之间有空格 ,将忽略该属性。我希望这可以帮助别人。