Vertically center <li> text with bullet image?
Asked Answered
R

2

7

So I am trying to figure out how I can vertically align some text that I have with a custom bullet image. Here is what I have:

<ul>
    <li>LINE OF TEXT</li>
    <li>LINE OF TEXT</li>
    <li>LINE OF TEXT</li>
</ul>

And for the CSS...

#div .class
{
    color: #4c361c;
    font-size: 13px;
    list-style-image: url(../images/image.png);
}

#div .class li{ }

Does anyone have anyideas on how to go about doing this?

Rounders answered 3/12, 2012 at 1:46 Comment(2)
Play with the line-height of the <li>s.Gerenuk
What is the dimension of your bullet image?Rosenberry
B
6

Here's a demo.

Using a background image can get you the desired effect.

HTML

<ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    <li>Four</li>
</ul>

CSS

ul {
    list-style: none;
}

ul > li {
  background: url('../imgpath/bullet-image.png') no-repeat left center;

  /* Adjust the padding for your custom bullet image */
  padding: 10px 0 10px 34px;
}
Bronwyn answered 3/12, 2012 at 2:8 Comment(1)
This solved my issue. Using list-style: none;, assign a background image to the li and use padding to have the text bumped out away from the bullet itself.Heartstrings
S
2

Now Define you li background bullets and set to background-position according to your design

as like this

Css

ul{
margin:0;
  padding:0;
  list-style:none;
}
li {
background:url("http://www.un.org/en/oaj/unjs/efiling/added/images/bullet-list-icon.jpg") no-repeat 0 -2px;
  padding-left:20px;
  line-height:14px;
  font-size:14px;
  margin-top:12px;
}

Live Demo

Squinty answered 3/12, 2012 at 5:8 Comment(1)
dead link I'm afraid :(Tyner

© 2022 - 2024 — McMap. All rights reserved.