Problem with IE position: absolute

2020-06-12 05:30发布

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?

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.

标签: html css
2条回答
淡お忘
2楼-- · 2020-06-12 05:58

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

<div style="position: absolute; top: 170px; left: 0px;">
查看更多
▲ chillily
3楼-- · 2020-06-12 06:06

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

top:(space)20px;

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

查看更多
登录 后发表回答