Vertical alignment in a div

N

Nik Coughin

How can I make something in a DIV vertically centered without using tables,
the CSS equivalent (if there is one) of <td valign="middle">?

ie:

--------------------------------------------
xxxxx
xxxxx
xxxxx This text is vertically centered
xxxxx
xxxxx
 
N

Nik Coughin

I like your way better. I already considered resorting to a table cell as
suggested by W3 (!), but didn't like the idea. Scoured Google for this for
a while, didn't find anything as elegant as that, got sick of wading through
the irrelevant bullshit. Thanks a heap.
 
B

brucie

in post: <
Nik Coughin said:
I already considered resorting to a table cell as
suggested by W3 (!), but didn't like the idea.

using the visual appearance of at table cell (css table model) is not
the same as using a html table.
 
N

Nik Coughin

Could you please repost this page? I'm getting a 404 Shit Not Found
error. (I've been out of the country and just got back, which is why
I didn't see it when you first posted it.)

One of the ways that it was done on that page (I made the original request)
was something like this:

..verticalcenter
{
vertical-align: middle;
}

....

<div>
<img src="Spacer.png" alt="" height="51" width="0" class="verticalcenter"
/>Some text
</div>

The text then appears vertically centered in that div. I think that the
height of the image is important, I seem to vaguely recall someone saying
that it had to be taller than the text (makes sense if you want to have
something to vertically center it against).

There was another method but the above one worked well for me.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top