Previous Message
Next Message

What's the proper way to vertically center an element within its parent?

Sent by Chris Chen on 5 March 2007 01:01


--===============0095482450==
Content-Type: text/plain; format=flowed

I just realized I only need one level of <div> here to achieve what I want.

Chris

> > > Whatever reason is the span there for?  There's nothing you can do 
>with
> >that
> > > construction that you can't do with just the link.
>
>This is for a horizontal navigation bar centered on the top of the page.
>
> > >
> >To add to that, if you want to adjust the vertical alignment within a 
>block
> >of text,
> >then you are on the right track with vertical-align (CSS property). Try
> >using
> >a percentage instead of one of the keywords, and see if you can get the
> >effect
> >you want. You can also use negative percents to drop it below the 
>baseline.
> >
> >Won't work in IE less than version 6, though. (Or any IE in quirks mode.)
>
>I have the following working satisfactorily in IE non-quirk mode: (no
>vertical-align needed for my case)
>
>         <div id="navigation_pane_outer">
>             <div id="navigation_pane_inner">
>                 <a class="link" href="#">Home</a>
>                 <a class="link" href="#">Schedule</a>
>                 <a class="link" href="#">Facilities</a>
>             </div>
>         </div>
>
>body
>{
>     text-align: center;
>}
>
>div#navigation_pane_outer
>{
>     width: 100%;
>}
>
>div#navigation_pane_inner
>{
>     width: 324px; /* 108 x 3 */
>}
>
>a
>{
>     display: block;
>     float: left;
>     line-height: 35px;
>     width: 108px;
>     background-image: url(../images/link.jpg);
>}
>
>The ugly part is to force <a> to a block. I might as well replace <a> with 
>a
>truely block element and change to use scripting to handle the visual cue
>change / click, but that would seem overkill for a simple task like this. 
>Is
>there a strong opposition to to the way I use <a> above for this task?
>
>By the way, in quirk mode, the above code annoyingly shows an extra "s"
>below the three <a>s on a separate line, but it disappears if I increase
>div#navigation_pane_inner's width from 324 to 327. Any idea?
>
>Thanks,
>Chris

_________________________________________________________________
Find a local pizza place, movie theater, and more….then map the best route! 
http://maps.live.com/?icid=hmtag1&FORM=MGAC01


--===============0095482450==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7 information -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
--===============0095482450==--
Previous Message
Next Message

Message thread:

Possibly related: