SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: vertically center text
-
Sep 12, 2007, 00:51 #1
- 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.
-
Sep 12, 2007, 01:36 #2
- Join Date
- Jul 2006
- Location
- Victoria, Australia
- Posts
- 4,122
- Mentioned
- 29 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.
-
Sep 12, 2007, 01:56 #3
- 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