This question already has an answer here:
Imagine a simple unsorted list with some <li>
items. Now, I have defined the bullets to be square shaped via list-style:square;
However, if I set the color of the <li>
items with color: #F00;
then everything becomes red!
While I only want to set the color of the square bullets. Is there an elegant way to define the color of the bullets in CSS...
...without using any sprite images nor span tags!
HTML
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<ul>
CSS
li{
list-style:square;
}
A variation of Lea Verou solution with perfect indentation in multi-line entries could be something like this:
I tried this and things got weird for me. (css stopped working after the
:after {content: "";}
part of this tutorial. I found you can color the bullets by just usingcolor:#ffffd;
on theli
item itself.Here's an example.
The easiest thing you can do is wrap the contents of the
<li>
in a<span>
or equivalent then you can set the color independently.Alternatively, you could make an image with the bullet color you want and set it with the
list-style-image
property.The current spec of the CSS 3 Lists module does specify the
::marker
pseudo-element which would do exactly what you want; FF has been tested to not support::marker
and I doubt that either Safari or Opera has it. IE, of course, does not support it.So right now, the only way to do this is to use an image with
list-style-image
.I guess you could wrap the contents of an
li
with aspan
and then you could set the color of each, but that seems a little hackish to me.Yet, another solution is to use a
:before
pseudo element with aborder-radius: 50%
. This will work in all browsers, including IE 8 and up.Using the
em
unit allows responsiveness to font size changes. You can test this, by resizing your jsFiddle window.jsFiddle
You can even play with the
box-shadow
to create some nice shadows, something that will not look nice with thecontent: "• "
solution.browsing sometime ago, found this site, have you tried this alternative?
sounds hard, but you can make your own png image/pattern here, then copy/paste your code and customize your bullets =) stills elegant?
EDIT:
following the idea of @lea-verou on the other answer and applying this philosophy of outside sources enhancement I've come to this other solution:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
and use the last part of f... followed by a number like this, with the
font-family
too:and that's it! now you have custom bullet tips too =)
fiddle