Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help With list-style-image

Tags:

css

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.

like image 612
Richard Knop Avatar asked Nov 20 '25 09:11

Richard Knop


2 Answers

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

.class li {
    vertical-align: middle;
}
like image 112
mkrause Avatar answered Nov 22 '25 05:11

mkrause


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);
}
like image 24
cast01 Avatar answered Nov 22 '25 04:11

cast01



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!