Vertically aligning all content in a div?

Associate
Joined
12 Aug 2004
Posts
1,009
Location
Glasgow, Scotland
Hi there,

A fairly simple css question here; I'm trying to figure out how to vertically align all the content in a div but just can't seem to get the vertical-align command to work :confused:

Is there something I have to specify for it to work, or is there any other method I could use?

Thanks
 
This is how I do it:

Code:
<div id="myDiv">Center</div>

div#myDiv {
  height: 100px;
  line-height: 100px;
}
 
hmm, that works if i want to center it vertically ... but that doesn't work if i need to align it to the bottom (which is what i need to do) :(
 
Depending on your markup, you can position: relative; the container element, and then position: absolute; bottom: 0; the inner element to align it to the bottom of the container.
 
Back
Top Bottom