Absolute Positioning & Text Alignment

The div doesn't take up all the available horizontal space when absolutely positioned. Explicitly setting the width to 100% will solve the problem:

HTML

<div id="my-div">I want to be centered</div>​

CSS

#my-div {
   position: absolute;
   bottom: 15px;
   text-align: center;
   width: 100%;
}


Try this:

http://jsfiddle.net/HRz6X/2/

You need to add left: 0 and right: 0 (not supported by IE6). Or specify a width


Maybe specifying a width would work. When you position:absolute an element, it's width will shrink to the contents I believe.


This should work:

#my-div { 
  left: 0; 
  width: 100%; 
}

Tags:

Html

Css