Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Getting text to align properly in list with custom bullet

Tags:

html

css

I am trying to get the text in my list to align properly, but I can't get it right.

enter image description here

As you can see the text is slightly off and starts at the "image bullet" baseline. I want it to be in the middle.

Source:

//CSS
ul  {
    list-style-image:url(image/li.png);
    list-style-position:outside;
    margin:0; padding:0;
}
ul li {
    margin:0; padding:0;
}

//HTML
<ul>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
</ul>
like image 706
jamietelin Avatar asked Nov 29 '12 11:11

jamietelin


People also ask

How do I align text with bullet points in CSS?

You need to bring the bullet points inside the content flow by using list-style-position:inside; , and then center align the text.

How do you align text with bullets in HTML?

You can use . parentOfUl{ text-align:center;} and then ul{ display:inline-block; }, and at last li{ text-align:center; }.


1 Answers

Now define your li background image and define background position according to your design

ul  {
    list-style:none;
     margin:0; padding:0;
}
ul li {
    margin:0; padding:0;
  background:url('') no-repeat 0 0;
  padding-left:40px;  // according to your image with
  min-height:40px; // according to your image height
}

Demo

DEMO2 As per OP's exact requirement

like image 161
Rohit Azad Malik Avatar answered Oct 05 '22 07:10

Rohit Azad Malik