January 13, 2004

CSS Centering

The other day my brother was having a problem getting an element to vertically centered using CSS. I knew I had seen something that dealt this exact issue. I also know I've done this in the past, but couldn't spout it off the tip of my tongue. Web Page Design for Designers has an editorial/example called Dead Centre that shows exactly how to do this. It's a nice demo. This is what I was recalling yesterday to try and show him a demo of what he needed.
Post Info

Tagged As CSS

Comments are Open (2)

Posted at 01:53 PM

Comments

David Dorward

Oh wow! Its possible! I thought it impossible!

... and it is - at least if you don't want it to break horribly when the user changes their font size.

thijs

I've been searching for a structural valid xhtml/css option to vertically align a block element for quite a while know. The dead centre example seems to work but when you change the doctype to xhtml 1.0 strict you will notice that ie 5+ mac will render the page incorrect. I know this browser is outdated but sometimes you really need your site to align weel across all major browsers and platforms.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu