Hi,
Whats the best approach to vertically center text in a li but restrict the text to less than 100% of the li width - in this case, setting the line-height on the li causes the wrapped text to have a massive line spacing (which of course with line-height you are telling it to do):
ul li {
height: 40px;
line-height: 3em;
border-bottom: 1px solid #103d3b;
padding-left: 10px;
font-size: 13px;
background-image: url(images/listarrow.png);
background-position: right center;
background-repeat: no-repeat;
}
<ul>
<li>test 1</li>
<li>test 2 which is a longer line and needs wrapping</li>
</ul>
Adding a div around the text with width of 80% and a line-height of 1em cancels out the line-height on the li and sends the (now correctly wrapped) text to the top of the li box.
What I want to do is have the text block vertically centered, with a normal line height, regardless of whether the text wraps or not.
Any ideas?
The only browser I am targetting with this is Mobile Safari (iPhone, iPad et al), so I can use solutions which only work on Safari if that is the only way. I don't want to do this in Javascript as that can be very detrimental with large lists.
Regards
Moo