Forum Moderators: not2easy
¦--- Div Link 1 ---¦--- HEADER ---¦--- Div Link 2 ---¦
Almost like three columns. However, HEADER is a bigger font size than the two links. How can I set it up so that when HEADER is bigger, the two links vertical align? Right now, they are at the top. I've tried height:100% and vertical-align:middle, but no dice.
Any ideas?
copy this code and tell me what you want it to do from here:
above the <head> tag:
<style type="text/css">
<!--
#left, #right {
float: left;
width: 20%;
background-color: #009999;}#middle {
float: left;
width: 60%;
font-size: xx-large;
background-color: #FFFFCC;}
-->
</style>
And below the <body> tag:
<div id="left">LEFT</div>
<div id="middle">MIDDLE</div>
<div id="right">RIGHT</div>
I would like the text on the left and the right to line up in the middle on the bigger text.
This is how your code comes out (the middle column is three lines to simulate a larger font): the dashes are used for spacing:
left side ¦ BIG FONT ¦ right side
----------¦ BIG FONT ¦-----------
----------¦ BIG FONT ¦-----------
----------¦ BIG FONT ¦-----------
left side ¦ BIG FONT ¦ right side
----------¦ BIG FONT ¦-----------
Thanks for any help!
#left, #right {
height:25px;
line-height:25px;}
This will cause the text to vertically align to center within the div.
However this only works for one line of text. If there is any line wrap at all, it won't work.
CSS1 specs do not have vertical alignment, unfortunately. So when you get into block displaying elements (like images or paragraphs), or more than one line of text, then vertical alignment is a lot harder to accomplish. The best way I've found to do it uses display:table (and some stuff that will make it work in IE, because IE will not recognize the "display:table" stuff), but it's dependent on knowing at least the height of an element - so if the height of the divs in question will stay at a certain height, then you're good (and search for "vertically align CSS jakpsatweb" for the tutorial on how to accomplish this). If the height of the header area is variable based on the length of one of the divs, you can *try* to make the heigh a little bit more flexible by doing it in EM's - but that'll only help if the text is enlarged by the end user - you'll need to use a table to get the effect you want.