SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Sydney, Australia
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    vertically center text

    Hey

    I changed an old site from table layout to div layout.
    Now i have a div which is 22px high 150 px wide and has a background image and text in it. In the table layout, the text was vertically centered. However in the div layout it is closer to the top. How can i vertically center it?

    Thanks.

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,119
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Hello,

    The easiest way to vertically center text is by giving it a line-height equal to the height of the element you are wanting it centered in.

  3. #3
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Sydney, Australia
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah, thank you very much, works!
    Most sites i searched for had things like using positioning for IE and display:table-cell and vertical-align: middle for all other browsers, but that didnt work well for just one word


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •