Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Beginner
Mar 13, 2000

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 element.style.left and element.style.top 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.

Deepak Pant
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap