Click to See Complete Forum and Search --> : Centering text vertically??


dmason165
03-24-2003, 09:43 AM
Hello all!

Is there any way to center text vertically?

All ideas welcome!

Thanks for your time and your help.

~dmason165

khaki
03-24-2003, 09:53 AM
Hi dmason165...

CSS aligns text vertically using this style:

vertical-align: middle

In a table, it's vAlign=middle

Are either of those what your looking for?
k

dmason165
03-24-2003, 10:07 AM
khaki,

Exactly what I'm looking for! Thank you! As you probably can tell, I'm pretty new at this;)

Thanks again!

~dmason165

PS. Is that YOUR picture?

khaki
03-24-2003, 10:18 AM
Hi again dmason165...

Well, if your new to all of this, I really hope that you will learn to layout your pages using CSS ... and not tables.

It will save you headaches in the future, and it's suprisingly much easier (less complex) than table layout.
Plus... there is a CSS forum here, so getting help should be no problem for you.

Anyway... I hope I have convinced you (and to answer your other question... yes).
vertically aligned to the middle... horizontally aligned slightly to the right...
;) k

dmason165
03-24-2003, 02:12 PM
Hello everyone!

I checked the answer given to me in a previous reply for aligning text vertically. It was correct. However, I can't get my text to cooperate.

Suggestions anyone?

Thanks!

~dmason165

khaki
03-24-2003, 03:23 PM
Hi dmason165...

Without seeing the code, it's not really possible to tell you what might be wrong.

It could be as simple as not placing a ; at the end of the style
(vertical-align: middle;)
... or it could be any number of things.

If you post your code for us, maybe we can spot what is causing your text to "not cooperate".
k

dmason165
03-24-2003, 04:40 PM
I've been pretty careful about syntax. I hope you'll be able to figure this out...I tried for a while with no luck.

Below, I have attached the code for my page.

Thanks again for all your help.

~dmason165

Kelley Poulos
03-24-2003, 07:24 PM
try adding this to your style statement on the <p> tag:
position: relative; top: 50%

I took your file, stripped out everything not needed for the centering (a whole bunch) and fiddled around with it until this worked.

Good luck

dmason165
03-24-2003, 08:35 PM
Kelley Poulos,

Thank you! What's weird is that 25% centered the "welcome". It doesn't make sense. If anyone could perhaps tell me why 50% worked for Kelley Poulos and 25% worked for me, I think a lot of people would benefit.

Thanks again Kelley!

~dmason165

Kelley Poulos
03-24-2003, 09:34 PM
I also made your font smaller. My guess is that the top of the text was centered. I used this to center an image and found 40% looked better to me. It's nice to have that much control, though.