tags:

views:

64

answers:

3

I have set an image 32x32px as a list style image like this:

.class li{
    list-style-image:url(../images/site/img.png);
}

It works great but the problem is the text is on the bottom of the list item (because the image is 32px high the list item is also 32px high). I would like to have the text vertically centered so it looks good.

I tried:

.class li{
    line-height:1em;
}

But that didn't help.

+3  A: 

You can use the vertical-align property to specify centered alignment. Like so:

.class li {
    vertical-align: middle;
}
mkrause
Hm, on second thought you might need more than just setting the li's vertical-align. Try wrapping your list content in an inline element (like `<li><span>...</span></li>`), then by playing with that span's line-height and vertical-align you should get the desired results.
mkrause
+2  A: 

the list-style-image tag should be applied to the list itself, and not the list item as you have.

so it would be..

ul.class{
    list-style-image:url(../images/site/img.png);
}
cast01
A: 

Setting your line-height to the height of the element will align text vertically. So if you <li> height is 32px then set your line-height to 32px.

.class li { height:32px; line-height:32px; list-style-image:url(img.png); }
jpdelatorre