View Single Post
10-04-2007, 03:47 PM
#1
TechnikCoding is offline TechnikCoding
Status: On Vacation
Join date: Sep 2007
Location:
Expertise:
Software:
 
Posts: 15
iTrader: 0 / 0%
 

TechnikCoding is on a distinguished road

  Old  The difinitive CSS centering?

Hey,

I come to you to pose a question that has definatly been asked many a time. What's the best way to center a div in CSS?

Normal instant response:
div {position:relative: top:0; margin:0 auto; width:Npx}

But is this always the best way of doing it? I've seen many other techniques each with thier own drawback. The drawback to this response is its not entirely browser compatible.

Other ways:
div {position:absolute; width:Npx; margin-left:-N/2px; left:50%;}

The second is completly browser safe, but in a browser smaller than N in width, the left gets cut off. Which is best. Due to me being a UK coder, i dont have an iphone yet, but i am sure i will have to re-invent some of my personal coding standards for it. /disucss?