Why don't negative fields work in IE 7?

I declared a negative margin by reference, but it does not work on IE 7.

#search a { color: #E5E5E5; text-decoration: none; font-weight: bold; float:right; margin-top:-20px; // this is not working on ie, only mozilla } 

Is there a fix for this?

+4
source share
3 answers

{position: relative;} may be required, as already noted, but you may have another problem:

In general, IE7 will not draw a part of an element that extends beyond its parent container if negative fields are the method used to extend the element in this way (although it will respect other ways to perform protrusions, for example {overflow: visible} ).

This is a bug related to "hasLayout", IE, and a thorough review can be found on "Layout: Negative Margin Error . "

As mentioned above, there are ways to persuade IE7 to draw a part of the element with negative fields that extends beyond its parent, but it includes "... do not use any properties that give the layout of the element." and this potentially limits the other design methods you would like to use and has other side effects (again, see the cited link).

But to answer your question: for a workaround, see the list of properties that call "hasLayout" in Get Me Layout! Please, (for example, position, height and width - yikes!) And make sure that none of them apply to your container.

+8
source

Set Position: Relative; This is a good guide for using negative fields http://www.smashingmagazine.com/2009/07/27/the-definitive-guide-to-using-negative-margins/

+1
source

Make sure you have a valid Doctype installed. Quirks mode does not allow negative fields.

+1
source

Source: https://habr.com/ru/post/1346594/


All Articles