兼容IE6的CSS-position:fixed 固定窗口位置显示效果.

CSS布局中
IE6默认不兼容position:fixed效果. 使用expression结合css hook可以做到兼容效果, 代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
            body{
                /* 这设置自己的背景图.如果没有就设置一个不存在的图片 目的是为了防止抖动 */
                background: url(*) fixed;
            }
            .fixed{
                min-width: 160px;
                min-height: 120px;
                /* IE6 hook */
                _width: 160px; _height: 120px;
                border: 10px solid red;
                position: fixed; _position: absolute; 
 
                /* 左上 */
                /*
                left: 0px; top: 0px;
                IE6 hook
                _left: expression(eval(document.documentElement.scrollLeft || document.body.scrollLeft)+'px');
                _top: expression(eval(document.documentElement.scrollTop || document.body.scrollTop)+'px');
                */
 
                /* 右下 */
                right: 0px; bottom: 0px;
                IE6 hook
                _left: expression(eval((document.documentElement.clientWidth || document.body.clientWidth)-this.offsetWidth+(document.documentElement.scrollLeft || document.body.scrollLeft))+'px');
                _top: expression(eval((document.documentElement.clientHeight || document.body.clientHeight)-this.offsetHeight+(document.documentElement.scrollTop || document.body.scrollTop))+'px');
            }

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.

Proudly powered by WordPress   Premium Style Theme by www.gopiplus.com