September 10, 201016 yr Hi I am trying to position fixed some image on my site however it doesn't show correctly in I.E. My current code is: <img src="image.jpg"; style="position:fixed; right:20px; top:200px"/> How can I make this work in IE?
September 10, 201016 yr How exactly is IE showing it? IE6 doesn't understand position:fixed, but I believe later versions do (someone may correct me though).
September 10, 201016 yr Author IE just puts the element on the top left corner of the page. I don't have my website online yet to give a link. So I can't do the effect I want in IE?
September 10, 201016 yr Well it should be fine in IE 7 onward, I've just checked that. Which version of IE are you using? You could post a screenshot.
September 12, 201016 yr Author Hi thanks for the responces. It is IE version 8. After you told me that for you it works, I tried it again with just that code and it worked. But when I put in my other content it doesn't. By removing elements one by one I found this to be causing the problem: <!--===================--> <!--Copyright (c) 2010 --> <!--===================--> As I'm sure you understand I added this to show that it's copyright content. I added it on the far top of the page before anything else -before the DOCTYPE and the <head> stuff. But if it's causing trouble that means that's not the right place to put that. So where should I put it? thanks
September 12, 201016 yr Author Also, in regards to the fact that fixed positioning does not work for IE 6 and downwards, I wanted to ask if there's a way to make this image get position absolute when in these browsers (at the same place on the page). In other words to write a code that sais that in all browsers be position:fixed, while from IE6 and downwards be position:absolute. Is there a way to do that? thansks
September 12, 201016 yr why bother with the copyright anyway? What exactly are you copyrighting? Anyway you can always use http://www.metatags.info/meta_name_copyright
September 12, 201016 yr I added it on the far top of the page before anything else -before the DOCTYPE and the <head> stuff. But if it's causing trouble that means that's not the right place to put that. So where should I put it? Don't ever put anything before the doctype. Put comments like that in the head section or the body section. In other words to write a code that sais that in all browsers be position:fixed, while from IE6 and downwards be position:absolute You may not need to do anything. IE6 won't process position: fixed; and usually just applies position: absolute. If you want to make sure, add in a conditional comment for IE6 right at the end of the head section, after any head section styles and links to stylesheets, but you will have to delete the position: fixed; from the inline style and add a id in the main stylesheet:- Main stylesheet CSS:- img#special { position:fixed; right:20px; top:200px; } Code last in head section:- <!--[if IE 6}> <style type="text/css"> img#special { position: absolute; } </style> <![endif]--> HTML markup with id but without inline style:- <img id="special" src="image.jpg" alt="image description" /> You have to delete the inline style because it would be processed last and you don't want that, you want the main style processed first for all browsers and then the conditional comment just for IE6. The position: absolute should put the image in the same place, but it will scroll in IE6 instead of staying fixed in the window.
Create an account or sign in to comment