How to fix Absolute Positioning In IE8?

后端 未结 6 1546
野性不改
野性不改 2020-12-24 14:16

In every browser I\'ve used, except ie8, an absolutely positioned element can be positioned according to the closest parent with relative positioning.

The below code

相关标签:
6条回答
  • 2020-12-24 14:32

    i´d always use the HTML5 doctype, but in my case the only problem was that the parent element needed "position:relative;" specifically set. after that, it worked perfectly fine.

    0 讨论(0)
  • 2020-12-24 14:37

    Declare a doctype. I'd encourage you to use the HTML5 doctype:

    <!DOCTYPE html>
    
    0 讨论(0)
  • 2020-12-24 14:44

    That's becuase you're not using the document type. And IE working in the "quircks" mode.

    Try this doctype:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    0 讨论(0)
  • 2020-12-24 14:49

    Microsoft Says :

    In most cases, we recommend that websites use the HTML5 document type to support the widest variety of established and emerging standards, as well as the broadest range of web browsers. This example shows how to specify the HTML5 document type.

    For more Info

    0 讨论(0)
  • 2020-12-24 14:50

    You can also use

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    

    This fixed my problem!

    0 讨论(0)
  • 2020-12-24 14:52

    Add this:

    #top {
    //height: 100%;
    }
    #position_me {
    //left: 0;
    }
    

    It forces IE8 to compute position correctly in quirks mode. There are many ways to get it:

    //zoom: 1;
    //writing-mode: tb-rl;
    

    See http://haslayout.net/haslayout

    0 讨论(0)
提交回复
热议问题