How to get “position:fixed” css to work in IE 7+ with TRANSITIONAL doctype?

前端 未结 2 1454
猫巷女王i
猫巷女王i 2020-11-27 21:11

I know that position:fixed; was not supported by IE until IE 7, and it only works in IE 7 if you have a STRICT DOCTYPE.

My question is: \"

2条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 21:46

    Fixed position does not work for me even with the Transitional/Strict Doc types. However I am using IE9 in compatibility mode and that is suppose to render using the IE8 runtime libraries. To fix this issue I had to add the following CSS to element.

    .elementToBeFixed {
        position: fixed;
        top: 0;
        left: 0;
    }
    

    It does not work with Top or Left being missing you have to explicitly set them to zero (or your desired value) for it to work in all versions of IE....Needless to say IE sucks.

提交回复
热议问题