Jump to content

Recommended Posts

Posted

I would like to center a div vertically within a containing div without having to manually figure the height of the containing div, and then applying the appropriate top margin to the inner div.

 

I know you can't use margin: auto 0;.

 

So, what are my options? Can I do this with javascript?

Posted

You can't make the inner div center vertically unless you give the container div a height to work within unless you use display: table and display: table-cell (unless javascript can do it).

 

See item 17f here

http://www.wickham43.net/firefoxbackground.php

where neither the container #displaytable, nor the middle div #displaytablecell2 nor the green div #nested have a height.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...