IE css expression(表达式)

很多时候我们需要对IE6的bug写一些hack,如max-height,absolute元素高度100%等。

css里面的 expression(表达式)和js里面的差不多,如:

获取当前元素的高度:

.box{
    height:expression(this.offsetHeight);
}

我们也可以获取到本身高度后再加减某个高度:

.box{
    height:expression(this.offsetHeight-30);
}

获取滚动的高度:

top:expression(eval(document.documentElement.scrollTop))}

获取父元素的高宽:

width:expression(this.parentNode.offsetWidth); 
height:expression(this.parentNode.offsetHeight); 

  

posted @ 2014-02-24 14:58  破男孩  阅读(1845)  评论(0)    收藏  举报