CSS question

babs

Can't get enough of FH
Joined
Dec 30, 2003
Messages
1,595
You know there's a problem when you come to this thread thinking someone had a problem with counter-strike: source.
 

Alliandre

Fledgling Freddie
Joined
Dec 28, 2003
Messages
202
babs said:
You know there's a problem when you come to this thread thinking someone had a problem with counter-strike: source.

It is in web dev..
 

babs

Can't get enough of FH
Joined
Dec 30, 2003
Messages
1,595
I know I know :( I feel ashamed enough already.

As for your question, google suggests 'vertical-align' but seems to say that it may work at inline level, not block level.

Here is one such example (and a fix of sorts).
 

Alliandre

Fledgling Freddie
Joined
Dec 28, 2003
Messages
202
Thanks. The work around does work :)

They should really have a valign that works with <p> and all the other tags though imo.
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
It make work, but hacking your markup to make the style work is one of the worst-kind-of-hacks. Maybe try looking into these for something more elegant:

From: http://www.evolt.org/article/Ten_CSS_tricks_you_may_not_know/17/60369/

8. Vertically aligning with CSS

Vertically aligning with tables was a doddle. To make cell content line up in the middle of a cell you would use vertical-align: middle. This doesn't really work with a CSS layout. Say you have a navigation menu item whose height is assigned 2em and you insert this vertical align command into the CSS rule. It basically won't make a difference and the text will be pushed to the top of the box.

Hmmm... not the desired effect. The solution? Specify the line height to be the same as the height of the box itself in the CSS. In this instance, the box is 2em high, so we would insert line-height: 2em into the CSS rule and the text now floats in the middle of the box - perfect!


Also consider looking at the CSS table properties (e.g. table-cell). I believe it's possible to declare a box (e.g. a <div> or a <p> or whatever) to be rendered like a table cell. Once that's done, you may be able to apply to vertical alignment to the element. The one above may be better though.

Ben.
 

Users who are viewing this thread

Top Bottom