How to center a div in the middle of the screen

nend

  • When is a theme, no longer what it was when installed?
  • Posts: 165
Re: How to center a div in the middle of the screen
« Reply #30, on April 23rd, 2012, 06:21 PM »
Quote from Nao on April 23rd, 2012, 06:00 PM
Yeah you don't, but it's cleaner to add it because vertical margins don't do anything when you set them to auto. 'margin: auto' might imply 'center horizontally and vertically' ;)
I never really thought of that, but I haven't seen a browser that did it both ways when just set to auto. Your right though it is better to set it that way, right now it doesn't have any effect setting it the other way, but maybe in the future it may. It is better to be compliant. ;)

*edit
Well in fact I have seen it done both ways, but this is when your in a container and a height is set for the container you are in. When a height isn't set it then it isn't a problem. :D