Sent by jeffrey morin on 28 April 2010 19:07
On Wed, Apr 28, 2010 at 1:40 PM, Jess Jacobs [EMAIL-REMOVED]>wrote:
> This might be a stupid question, but here goes:
>
> I have a div. I can set a width on that div and set margin: 0 auto; and
> have
> the thing centered horizontally.
>
> If I instead set a height on the same div, and then set margin: auto 0; it
> does not center horizontally.
>
> Why? why why why?
>
> Would the block center vertically if the containing block had a declared
> height, or does that not matter either?
>
> People are increasingly asking me to center things, or make the page
> flexible/collapsible, etc, but aren't using any of the kinds of designs
> that
> lend themselves to such things, and I'm not in a position to push back,
> unfortunately.
>
> Thoughts?
>
> ========================
> Jess Jacobs
> [EMAIL-REMOVED]
> http://www.akisma.com
> ______________________________________________________________________
> css-discuss [EMAIL-REMOVED]]
> http://www.css-discuss.org/mailman/listinfo/css-d
> List wiki/FAQ -- http://css-discuss.incutio.com/
> List policies -- http://css-discuss.org/policies.html
> Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
>
You could set your container to position: absolute top: 50%; and then set a
negative top margin to line it up. That worked for me before. Here is a link
I just found.
http://www.jakpsatweb.cz/css/css-vertical-center-solution.html
It looks like that example uses this but without the negative top margin.
You would use the top negative margin to bring your div up
Jeff
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/