How can I change the bullet points in an HTML list and use the glyphicons that come with Bootstrap 3?
So that:
<ul>
<li>...</li>
<li>...</li>
</ul>
Displays as:
[icon] Facere possimus, omnis voluptas assumenda est, numquam eius modi
omnis dolor repellendus. Non numquam eius modi numam dolor omnis
tempora incidunt ut labore.
[icon] Facere possimus, omnis voluptas assumenda est, numquam eius modi
omnis dolor repellendus. Non numquam eius modi numam dolor omnis
tempora incidunt ut labore.
I would prefer not to have to inject extra HTML such as this...
<ul>
<li><i class="glyphicon glyphicon-chevron-right"></i> ...</li>
<li><i class="glyphicon glyphicon-chevron-right"></i> ...</li>
</ul>
This isn't too difficult with a little CSS, and is much better than using an image for the bullet since you can scale it and colour it and it will keep sharp at all resolutions.
Find the character code of the glyphicon by opening the Bootstrap docs and inspecting the character you want to use.
Use that character code in the following CSS
You may like to tweak the colour and margins to suit your font size and taste.
View Demo & Code
If anyone is coming here looking to do this with Font Awesome Icons (like I was) view here: https://fortawesome.github.io/Font-Awesome/examples/
The
fa-ul
andfa-li
classes easily replace default bullets in unordered lists.I'm using a simplyfied version (just using position relative) based on @SimonEast answer:
If you want to have a different icon for each list-item, I suggest adding icons in HTML instead of using a pseudo element to keep your CSS down. It can be done quite simply as follows:
-
In this case I used Material Design Icons
VIEW DEMO
If you want happen to be using LESS it can be achieved like so:
Using Font Awesome 5, the markup is a bit more complex than the previouis answer. Per the FA documentation, the markup should be: