如何替换CSS表达式 [英] How to Replace CSS Expressions

查看:50
本文介绍了如何替换CSS表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于时间表条目的旧ASP Web应用程序,其中充斥着CSS表达式.它们出现在CSS文件中:

I have an old ASP web application for Time Sheet entry which is riddled with CSS expressions. They appear in the CSS file:

.ApptPage {
    position            : relative;
    height              : expression(Math.max(document.body.offsetHeight-this.offsetTop-document.body.marginTop,0));
    border              : 0 solid black;
}

和在ASP中:

<IFRAME SRC="TimeSheetView.asp?<%=sQueryStandard%>" id=frameContent style="border-left:0;position:absolute;top:0;width:expression(Math.max(0,divContent.offsetWidth-20));height:expression(Math.max(0,divContent.offsetHeight-this.offsetTop));border:0px;left:0px;"></IFRAME>

该应用程序可在IE上正常运行,但经过10多年的使用,我们希望在未来10年内为它做好准备,并使它与浏览器无关.

The application works fine for IE but after over 10 years of use we want to make it ready for the next 10 years and make it browser agnostic.

这是我第一次看到CSS中的表达式,我为寻找替换它的方法而茫然不知所措?有人有建议吗?

This was the first time I ever saw an expression in CSS and I am at a loss for finding a way to replace it? Does anyone have a suggestion?

推荐答案

在IE11中,不支持使用表达式的动态CSS.现在,您可以做两件事.

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

  • 更改特定元素的高度

var singleElement = document.getElementById("yourElement");
if (singleElement)
 singleElement.style.height =
          Math.max(document.body.offsetHeight-this.offsetTop-document.body.marginTop,0) + "px";

  • 更改所有使用该类的元素的高度"值

    var allElements = document.getElementsByClassName("ApptPage");
    //Now loop through 'allElements' and set singleElement.style.height
    

  • 这篇关于如何替换CSS表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆