Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE 7 negative margin error

With this code the "TEXT" doesn't show up in IE 7. I think its behind the input? Giving it a zindex dosn't help, and i can't use position:relative because it messes other stuff up. any ideas of how to fix?

<!DOCTYPE html>
<input/><span style='margin-left:-50px;'>TEXT</span>
like image 716
John Stimac Avatar asked Feb 26 '23 17:02

John Stimac


2 Answers

Same thing in IE 6. Adding position: absolute; solved it in IE 6, so hopefully it does the same in IE 7:

<span style='margin-left:-50px; position: absolute;'>TEXT</span>
like image 128
Gert Grenander Avatar answered Mar 08 '23 06:03

Gert Grenander


Margins are not reliable on inline elements. Newer browsers handle it ok, but older ones still don't work the way you expect them to in many cases. So you may need to make the element a block level element (which will then cause you to potentially need to use a float to bring it back inline before positioning it over the form element, which is what I assume is the intended final position.

Also, z-index will only work for elements that are positioned. I'm surprised that position: relative messes other things up, but position: absolute doesn't, my go to fix would be to use { position: relative; left: -50px; z-index: 10; } to slide the span over.

like image 35
LocalPCGuy Avatar answered Mar 08 '23 05:03

LocalPCGuy