📜 ⬆️ ⬇️

Practical JS: we optimize CSS expressions

Note: Below is a translation of the article "CSS Expression Optimization" , in which the author covers a little bit about the use and perspective of dynamic properties in CSS ( aka CSS expressions ). The author also proposes a way to optimize them (execution only once instead of constant execution). Below are a few abstracts from ClientSide'2007 on the stated subject. My comments are in italics.

CSS expressions were first introduced in Internet Explorer 5.0, which allowed you to assign a JavaScript expression as a CSS property. For example, the following code will allow to place an element depending on the size of the browser window.

 #myDiv {
    position: absolute;
    width: 100px;
    height: 100px;
    left: expression (document.body.offsetWidth - 110 + "px");
    top: expression (document.body.offsetHeight - 110 + "px");
    background: red;
 }

')
Not the best way to solve the problem, but as an example it is enough.

read further on webo.in →

Source: https://habr.com/ru/post/31374/


All Articles