Jump to content

Make Div Valign Center


loonie35

Recommended Posts

This is one of the remaining weaknesses in HTML. Some elements change their own alignment when vertical-align is set. Others change the alignment of things that they contain. An ordinary div cannot center its contents vertically with the vertical-align property. So vertical-alignment is a weird property.A trick sometimes used to to set the display property of a div to table-cell. vertical-align: center will then work in most browsers (it might even be the default? I don't recall). But this trick does not work in IE. Just as bad, vertical-align is not compatible with the float property. Add a float property, and the vertical-alignment fails.Some hacks are available here: http://www.google.com/search?q=css+vertical+centering

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...