Saturday, October 30, 2010

CSS Javascript quickie

Center (Centre) a div

Its easy, but its not necessarily obvious. To centre a div you need to set the width, and the margin-left and right to auto,



width: 500px; margin-left: auto ; margin-right: auto ;


To center text within a div use.

text-align: center ;


Useful links explaining with nice and simple explanations of objects in javascript (I wonder how I never “got it” before considering how simply its described here)

Also the prototype modifier. Basically it allows properties, and methods to be added to objects. Effectively making javascript OO, instead of purely functional.

No comments: