Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - Vertical alignment in a div

 
Thread Tools Search this Thread
Old 01-21-2004, 12:33 AM   #1
Default Vertical alignment in a div


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
--------------------------------------------

Where x represents space used by an image




Nik Coughin
  Reply With Quote
Old 01-21-2004, 01:17 AM   #2
brucie
 
Posts: n/a
Default Re: Vertical alignment in a div

in post: <news:bNjPb.18673$>
"Nik Coughin" <nrkn!no-spam!@woosh.co.nz> said:

> --------------------------------------------
> xxxxx
> xxxxx
> xxxxx This text is vertically centered
> xxxxx
> xxxxx
> --------------------------------------------
>
> Where x represents space used by an image


theres a few different ways to do it. heres one:
http://moreshit.bruciesusenetshit.in...gn-thingy.html

heres another one:
http://www.w3.org/Style/Examples/007....html#vertical

or you can use margins/padding

--
brucie - i usenet nude
  Reply With Quote
Old 01-21-2004, 01:35 AM   #3
Nik Coughin
 
Posts: n/a
Default Re: Vertical alignment in a div

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.

"brucie" <****@bruciesusenetshit.info> wrote in message
news:bukjuo$ivc9i$...
> in post: <news:bNjPb.18673$>
> "Nik Coughin" <nrkn!no-spam!@woosh.co.nz> said:
>
> > --------------------------------------------
> > xxxxx
> > xxxxx
> > xxxxx This text is vertically centered
> > xxxxx
> > xxxxx
> > --------------------------------------------
> >
> > Where x represents space used by an image

>
> theres a few different ways to do it. heres one:
> http://moreshit.bruciesusenetshit.in...gn-thingy.html
>
> heres another one:
> http://www.w3.org/Style/Examples/007....html#vertical
>
> or you can use margins/padding
>
> --
> brucie - i usenet nude



  Reply With Quote
Old 01-21-2004, 01:36 AM   #4
Nik Coughin
 
Posts: n/a
Default Top posted

Oops, top-posted. Sorry.


  Reply With Quote
Old 01-21-2004, 01:46 AM   #5
Mark Parnell
 
Posts: n/a
Default Re: Top posted

On Wed, 21 Jan 2004 14:36:37 +1300, "Nik Coughin"
<nrkn!no-spam!@woosh.co.nz> declared in alt.html:

> Oops, top-posted. Sorry.


http://home.in.tum.de/~jain/software/oe-quotefix/

--
Mark Parnell
http://www.clarkecomputers.com.au
  Reply With Quote
Old 01-21-2004, 02:05 AM   #6
Nik Coughin
 
Posts: n/a
Default Re: Top posted

Mark Parnell wrote:
> On Wed, 21 Jan 2004 14:36:37 +1300, "Nik Coughin"
> <nrkn!no-spam!@woosh.co.nz> declared in alt.html:
>
>> Oops, top-posted. Sorry.

>
> http://home.in.tum.de/~jain/software/oe-quotefix/


Thanks


  Reply With Quote
Old 01-21-2004, 06:48 AM   #7
brucie
 
Posts: n/a
Default Re: Vertical alignment in a div

in post: <news:yHkPb.18729$>
"Nik Coughin" <nrkn!no-spam!@woosh.co.nz> 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.


--
brucie - i usenet nude
  Reply With Quote
Old 01-24-2004, 05:50 PM   #8
Lauri Raittila
 
Posts: n/a
Default Re: Vertical alignment in a div

In article brucie wrote:
> in post: <news:bNjPb.18673$>
> "Nik Coughin" <nrkn!no-spam!@woosh.co.nz> said:


[vertical-centering]

> theres a few different ways to do it. heres one:
> http://moreshit.bruciesusenetshit.in...gn-thingy.html
>
> heres another one:
> http://www.w3.org/Style/Examples/007....html#vertical
>
> or you can use margins/padding


Some more methods here:

http://www.student.oulu.fi/~laurirai/www/css/middle/


--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

  Reply With Quote
Old 01-28-2004, 09:59 PM   #9
delerious@no.spam.com
 
Posts: n/a
Default brucie: Re: Vertical alignment in a div

On Wed, 21 Jan 2004 11:17:38 +1000, brucie <****@bruciesusenetshit.info>
wrote:
>theres a few different ways to do it. heres one:
>http://moreshit.bruciesusenetshit.in...gn-thingy.html


Could you please repost this page? I'm getting a 404 **** 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.)


>
>heres another one:
>http://www.w3.org/Style/Examples/007....html#vertical
>
>or you can use margins/padding
>
>--
>brucie - i usenet nude


  Reply With Quote
Old 01-28-2004, 10:08 PM   #10
Nik Coughin
 
Posts: n/a
Default Re: brucie: Re: Vertical alignment in a div

wrote:
> On Wed, 21 Jan 2004 11:17:38 +1000, brucie
> <****@bruciesusenetshit.info> wrote:
>> theres a few different ways to do it. heres one:
>> http://moreshit.bruciesusenetshit.in...gn-thingy.html

>
> Could you please repost this page? I'm getting a 404 **** 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.)
>
>
>>
>> heres another one:
>> http://www.w3.org/Style/Examples/007....html#vertical
>>
>> or you can use margins/padding
>>
>> --
>> brucie - i usenet nude


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.


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump