List Item Bullet Color different List Text Color
Recently ran into a design that asked for list items to have a different color for the bullet than the accompanying text. Rather than use a bullet image - the design was using the default bullet styles after all - I Came up with a quick solution with jQuery that I figured I'd share.
I started by setting the li color to the color I wanted the bullets to be. We'll go with
skyblue
for this.
-
Yo quiero leche. Yo quiero leche de madre. It's sort of like going from prime rib to… I don't know… weird brother of prime rib. I know she's a brownish area! With points! And I love her!
-
What is she doing at a beauty pageant? Is she running the lights or something? No one was making fun of Andy Griffith.I will be a bigger and hairier mole than the one on your inner left thigh! And that is why Jesus was often referred to as the King of Kings. Queens. The King of Queens.
-
I can't emphasize that enough. Michael was concerned that he was caught in a lie about his family.The family was concerned that they were being confronted by a woman they had clubbed, drugged, and left on a bench.
Remember though, we don't want the text to be
skyblue
, just the bullet. The next ul will get a class for our jQuery to target. We're also going to create a css property for spans appearing inside an li that contains the color we want it to be. In this case I want the color to be the same as the text color on the rest of the page - white.
Now we just write a quick bit of jQuery to wrap all of the text inside these li in spans. My code varies a bit so you can see the difference but you could use something like:
(function($) {
var listItems;
function onDocumentReady() {
listItems = $("li");
listItems.wrapInner("<span />");
}
$(onDocumentReady);
})(jQuery);
Voila!
skyblue
bullets and white text:
-
If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar. I believe you will find the dessert to be both engrossing and high-grossing! So we don't get dessert? The worst that could happen is that I could spill coffee all over this $3,000 suit.
-
COME ON. "Circumvent." It means "to go around." Gob: The old "reach around." I'm gonna build me an airport, put my name on it. Why, Michael? So you can fly away from your feelings? Daddy horny, Michael.
-
Someone order 140 pounds of upper body strength? But anyhoo, can you believe that the only reason the club is going under is because it's in a terrifying neighborhood? It's so watery. And yet there's a smack of ham to it. Gosh Mom… after all these years, God's not going to take a call from you.
This will work for ordered lists as well if you want it to. You could change your jQuery context to only target li inside ul if you needed to: $('ul').find('li'); would do the trick.
-
If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar. I believe you will find the dessert to be both engrossing and high-grossing! So we don't get dessert? The worst that could happen is that I could spill coffee all over this $3,000 suit.
-
COME ON. "Circumvent." It means "to go around." Gob: The old "reach around." I'm gonna build me an airport, put my name on it. Why, Michael? So you can fly away from your feelings? Daddy horny, Michael.
-
Someone order 140 pounds of upper body strength? But anyhoo, can you believe that the only reason the club is going under is because it's in a terrifying neighborhood? It's so watery. And yet there's a smack of ham to it. Gosh Mom… after all these years, God's not going to take a call from you.
Have you encountered this problem? What's your go-to solution? Let me know in the comments. If you have questions you can tweet @thatseandempsey or email, skd.developer@gmail.com.