Hans Gans
02-22-2005, 05:05 PM
Simple problem, easy solution?
I want a horizontal (navigation) bar with some text aligned left and some right, centered vertically. The following table code does that easily:
<table style="width: 100%; height: 10%; background: #CCC"><tr>
<td style="text-align: left">left</td>
<td style="text-align: right">right</td>
</tr></table>
How do I do that with CSS?
I tried several approaches:
Floating div's, aligned left and right. Ugly breaks if I shrink the window. Problem getting both div's to have the same height with different size fonts. If I specify a height, the vertical middle alignment is gone.
div for left part, absolutely positioned span for right part. Problems with vertically middle alignment.
Two span's with "text-align: left" and right. Right alignment is ignored.
The hard part is to get both the height of the bar and the middle vertical alignment right. As soon as I specify a height, the vertical alignment is gone:
<div style="background: #CCC; height: 30px">
hello charlie
</div>
adding a "vertical-alignment: middle" is ignored both in FF and IE. Any suggestions?
Regards,
Hans
I want a horizontal (navigation) bar with some text aligned left and some right, centered vertically. The following table code does that easily:
<table style="width: 100%; height: 10%; background: #CCC"><tr>
<td style="text-align: left">left</td>
<td style="text-align: right">right</td>
</tr></table>
How do I do that with CSS?
I tried several approaches:
Floating div's, aligned left and right. Ugly breaks if I shrink the window. Problem getting both div's to have the same height with different size fonts. If I specify a height, the vertical middle alignment is gone.
div for left part, absolutely positioned span for right part. Problems with vertically middle alignment.
Two span's with "text-align: left" and right. Right alignment is ignored.
The hard part is to get both the height of the bar and the middle vertical alignment right. As soon as I specify a height, the vertical alignment is gone:
<div style="background: #CCC; height: 30px">
hello charlie
</div>
adding a "vertical-alignment: middle" is ignored both in FF and IE. Any suggestions?
Regards,
Hans