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,

e.g.

#div{

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

}

To center text within a div use.

text-align: center ;

http://www.thesitewizard.com/css/center-div-block.shtml

Javascript

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)

http://javascriptkit.com/javatutors/object3.shtml

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

http://www.javascriptkit.com/javatutors/proto4.shtml

No comments: