Use JavaScript expressions in CSS expressions. The CSS attribute is set based on the calculation result of the Javascript expression.
CSS expressions do not work in other browsers, so they are useful when setting ieseparately in cross-browser encoding.
CSS expressions are supported from ie5. Let's take a look at the following Code:
Copy codeThe Code is as follows: Background-color: expression (new date (). gethours () % 2? "# F00": "# 00f ");
The above Code uses CSS expression to switch the background color every hour.
The problem with CSS expression is that its computing frequency is much higher than imagined. Not only when the page is displayed and scaled, but when the page is scrolling or even moving the mouse, it is re-computed. Add a counter to the CSS expression to track the computing frequency of the expression. You can easily move the mouse over 10000 times on the page.
One way to reduce the number of CSS expressions is to use a one-time expression. It assigns the result to the specified style attribute during the first run and uses this attribute to replace CSS expression.
If the style attribute must be dynamically changed within the page cycle, it is feasible to use the event handle instead of the CSS expression. If CSS expressions are required, remember that they must be calculated thousands of times and may affect the performance of your page. Do not make your users feel that opening your page will slow down.