How to Replace CSS Expressions

左心房为你撑大大i 提交于 2019-12-06 09:51:59

These expressions were specific to IE, but they are deprecated and abandoned, even by IE:

Ref: http://msdn.microsoft.com/en-us/library/ms537634%28v=vs.85%29.aspx

As of Windows Internet Explorer 8, dynamic properties have been deprecated and are only supported for Web pages displayed in IE5 (Quirks) mode or IE7 Standards mode.

and

Dynamic properties (also called "CSS expressions") are no longer supported in Internet Explorer 8 and later, in IE8 Standards mode and higher.

You can use JavaScript or CSS or a combination of both to achieve what these expressions are doing.

I'm not sure what/how exactly the expressions calculate, but I solved a similar problem (i.e. I needed dynamic heights) a while ago with the help of the descriptions and examples given on http://help.dottoro.com/. Just enter the terms (offsetWidth, offsetHeight, offsetTop, marginTop) one by one in the search field and hit Enter.

You should have a working knowledge of javascript, though. Because that is what you have to use to replace these expressions. There are developments on the CSS front regarding dynamic dimensions, but those styles are not supported by IE7-9, so that is no use.

In IE11, dynamic CSS using expression is not supported. Now, there are two things you can do.

  • Change height of a specific element

    var singleElement = document.getElementById("yourElement");
    if (singleElement)
     singleElement.style.height =
              Math.max(document.body.offsetHeight-this.offsetTop-document.body.marginTop,0) + "px";
    
  • Change the 'height' value of all elements which use the class

    var allElements = document.getElementsByClassName("ApptPage");
    //Now loop through 'allElements' and set singleElement.style.height
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!