...

View Full Version : centering a link in a cell



ali haydar
02-13-2012, 07:56 AM
hi everybody,

i'm putting a link inside a cell, and trying to make the entire cell clickable.. but when i do this can't make it vertically centered.. any help?




<table width="300" height="300" border="2" cellspacing="1" cellpadding="1">
<tr>
<td align="center"><a href="#">ali</a></td>
<td align="center">veli</td>
</tr>
<tr>
<td width="150" height="150" align="center"><a style="display:block;width:100%;height:100%;" href="#">kofte</a></td>
<td align="center">pilav</td>
</tr>
</table>

tomtrain
02-13-2012, 08:09 AM
First, to center that link for kofte, you use line-height:150px;. Second, to make the entire cell clickable, I took the style out of your link tags and created a div element inside of them, so that anything within the div (the entire cell) is the link. Here is the code:



<table width="300" height="300" border="2" cellspacing="1" cellpadding="1">
<tr>
<td align="center"><a href="#">ali</a></td>
<td align="center">veli</td>
</tr>
<tr>
<td width="150" height="150" align="center"><a href="href="#"><div

style="display:block;width:100%;height:100%;vertical-align:center;line-height:150px;">kofte</div></a></td>
<td align="center">pilav</td>
</tr>
</table>


If you have any problems with the other cells losing their centering, it may be because you are using align="center". You may want to switch them to "style="width:150px;height:150px;text-align:center;line-height:150px;" at some point.

ali haydar
02-13-2012, 08:46 AM
thank you very much, that works..



is there any other solution to this other than line-height solution.. because it doesn't work with opera mini.. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum