> -----Original Message-----
> From: Claude Needham [mailto:gxx...@gmail.com]
> Sent: Tuesday, September 14, 2010 5:04 PM
> To: Climis, Tim
> Cc: Chris Blake; css discuss discuss
> Subject: Re: [css-d] Can i vertically centre a UL?
> 
> On Tue, Sep 14, 2010 at 1:47 PM, Climis, Tim <tcli...@indiana.edu>
> wrote:
> >> I'd like it to sit right in the middle both vertically and
> >> horizontally without using padding or anything like that because it's
> >> dynamically fed.
> >> is there such a way using CSS?
> > As far as I know, not with anything with a dynamic height.  You can do
> it with javascript, but that's off-topic for the list.  And you can do it with
> CSS if the height is fixed.  But I think that's it.
> > ---Tim
> 
> Could you give a pointer on how to do this given fixed height ul?
> The only method I know of requires that both the containing element
> and the ul have fixed height. If there is a way to do this with dynamic
> containing element and fixed height ul that would be great.
 
Maybe I'm too tired.

Given:

<div><ul></ul></div>

I think

div {position: relative};
ul {
  position: absolute;
  top: 50%;
  height: 5em;
  margin-top: -2.5em;
}

does it.  Or does the div need a height too?  Okay, in this case it would, 
since there's nothing *in* the div, but in a similar case, where the div has 
other contents to give it an implicit height.

---Tim

______________________________________________________________________
css-discuss [cs...@lists.css-discuss.org]
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/

Reply via email to