I am trying to set custom image as a bullet. when i am using background or background-image tag it is work but not align properly with list category. And when i am using list-style-image it is not displaying the image as a bullet.
Problem :
Css
Firebug
Image is also displaying in firebug when i move my mouse over on it
Wrong final output
Solution :
Correct Output what i want
To change the bullet to an image, we will add two new CSS classes one for the <ul> element the other one for the <li> element. For the list class, we will set the padding and the margin to "0" and set the list-style-type to none.
Firstly, you need to create the List Item using a li list item tag. Within that List Item tag, you can place your image. You add an image within the Image tag img.
On the Home tab, in the Paragraph group, click the arrow next to Bullets, and then click Define New Bullet. In Word for Windows: Click Symbol or Picture, and then choose any symbol or picture that you want to use.
Here's one method that I tend to lean on. Add a before
to the li
, size it as required and add a background image to it.
Then just sprinkle some flexbox on to stop the text wrapping underneath the bullet.
I made a quick jsfiddle to demonstrate it
li {
display: flex;
align-items: center;
margin: 10px 0;
line-height: 30px;
list-style: none;
}
li:before {
display: block;
flex-shrink: 0;
width: 33px;
height: 33px;
margin-right: 10px;
vertical-align: middle;
background: url('https://image.flaticon.com/icons/png/128/1168/1168671.png') no-repeat left center;
background-size: contain;
content: '';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With