Advertisement
pusatdata

Replacing list bullets with images for different categories

Aug 9th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. You can disable the bullets using the list-style-type: none css rule and then use a background-image css style on the list item, or include a span (or some other element) inside the list item which would display the icon.
  2.  
  3. Something like this:
  4.  
  5. li {
  6. list-style-type: none;
  7. }
  8.  
  9. .icon-play,
  10. .icon-eat
  11. {
  12. height: 20px;
  13. width: 20px;
  14. display: inline-block;
  15. background-repeat: none;
  16. }
  17.  
  18. .icon-play
  19. {
  20. background-color: #f08080;
  21. /* use a background image here */
  22. }
  23.  
  24. .icon-eat
  25. {
  26. background-color: #80f080;
  27. /* use a background image here */
  28. }
  29. <ul>
  30. <li><span class="icon-play"></span> Let's Play</li>
  31. <li><span class="icon-eat"></span> Let's Eat</li>
  32. </ul>
  33.  
  34. ---
  35. And the css rules:
  36.  
  37. li {
  38. list-style-type: none;
  39. }
  40. .icon-play {
  41. display: inline-block;
  42. width: 20px;
  43. height: 20px;
  44. background-image: url(Img/wmd-buttons.png?v=581875b1c136);
  45. background-repeat: no-repeat;
  46. }
  47.  
  48. ==================================
  49.  
  50. You could also apply this to pseudo elements
  51. <li class="image-eat">Let's Eat</li>
  52.  
  53. and the CSS
  54. li:before { content: ''; display: inline-block; width: 5px; height: 5px; } .image-eat:before { background: url(); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement