Log in

View Full Version : vertical align in list



lord22
11-04-2009, 06:07 PM
Hi,

I have a simple unordered list:


<ul>
<li style="height:25px; width:25px; text-align:center;"><a href="1.html">1</a></li>
<li style="height:25px; width:25px; text-align:center;"><a href="2.html">2</a></li>
<li style="height:25px; width:25px; text-align:center;"><a href="3.html">3</a></li>
</ul>


How can I have the links vertically centered inside the li's?

Thanks!

maneetpuri
11-05-2009, 07:51 AM
Hi,

You can apply some padding to get it in the middle.

<ul>
<li style="height:25px; width:25px; padding-top:8px; text-align:center;"><a href="1.html">1</a></li>
<li style="height:25px; width:25px; text-align:center; padding-top:8px"><a href="2.html">2</a></li>
<li style="height:25px; width:25px; text-align:center; padding-top:8px"><a href="3.html">3</a></li>
</ul>

Hope This Helps,
Cheers,

Moshambi
11-05-2009, 08:11 AM
You can also try applying a line-height:


<li style="height:25px; width:25px; line-height: 1.5em; text-align:center;"><a href="1.html">1</a></li>

monicasaha
11-05-2009, 09:39 AM
make height and line-height same