vertical-align and div

Discussion in 'HTML' started by Jochen Fuhrmann, Oct 6, 2003.

  1. hi, why doesn't the vertical-align work here:

    div.test {top:10px;
    left:10px;
    width:230px;
    height:90px;
    text-align:center;
    vertical-align:middle;}

    i want to put the text in the center of the block

    jochen
     
    Jochen Fuhrmann, Oct 6, 2003
    #1
    1. Advertising

  2. Jochen Fuhrmann

    Steve Pugh Guest

    "Jochen Fuhrmann" <> wrote:

    >hi, why doesn't the vertical-align work here:
    >
    >div.test {top:10px;
    > left:10px;


    Are you specifying position somewhere else? top and left only apply
    when an element has a position value other than static (the default).

    > width:230px;
    > height:90px;
    > text-align:center;
    > vertical-align:middle;}


    Because vertical-align only applies in two cases -
    1. inline elements where it aligns the element relative to the
    surrounding line of text
    2. table cell elements where it aligns the content relative to the
    cell

    It does not apply to block level elements.

    http://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align

    You can convert a block element like <div> into a teble cell element
    by using display: table-cell; but IE doesn't support that.

    >i want to put the text in the center of the block


    http://www.aspekt1.net/ms/dev/vertical-align.html

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
     
    Steve Pugh, Oct 6, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kay
    Replies:
    2
    Views:
    7,171
  2. Tobias Müller

    div and vertical align

    Tobias Müller, Nov 25, 2003, in forum: HTML
    Replies:
    2
    Views:
    685
    Steve Pugh
    Nov 25, 2003
  3. Paul Lautman
    Replies:
    6
    Views:
    50,146
    Yucky Korpulent
    Apr 3, 2006
  4. =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=

    [CSS] Div-Tag and Vertical Align

    =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=, Aug 19, 2006, in forum: HTML
    Replies:
    6
    Views:
    22,542
    dorayme
    Aug 22, 2006
  5. Replies:
    3
    Views:
    1,027
    Jonathan N. Little
    Sep 22, 2006
Loading...

Share This Page