Use Appropriate Properties for CSS Positioning

When using CSS (Cascading Style Sheets) positioning, you can apply a number of techniques to make your code faster. When accessing and setting the position of an element, instead of using and properties, you should use posLeft, posTop, posWidth, and posHeight properties. The problem is that the left property is returned as a string and if you want to do math on the returned value, then it first needs to be converted from a string to an integer.

The posLeft, posTop, posWidth, and posHeight properties are floating-point representations of their corresponding string property. By using these properties, you will write smaller and much faster code. Speed becomes more important when the position is constantly being updated to perform an animation effect.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: