HTML special characters in CSS “content” attribute

前端 未结 3 1556
悲&欢浪女
悲&欢浪女 2020-12-29 09:17

I\'m trying to add content to something before an item using the CSS :before + content: fields. I want to insert a checkmark (☑), BUT if I use that in the content opti

相关标签:
3条回答
  • 2020-12-29 09:24

    Try this:

    #target:before {
      content: "\2611";
    }
    
    0 讨论(0)
  • 2020-12-29 09:30

    Use the checkbox character literally in your CSS rule instead of the encoding -

    #target:before {
        content: "☑";
    }
    

    See: http://jsfiddle.net/e3Wt2/

    0 讨论(0)
  • 2020-12-29 09:45

    You need to use Unicode values inside the content property. (The list of miscellaneous symbols may also be useful.)

    A heavy checkmark is listed as U+2713 so you would put content: "\2713";

    0 讨论(0)
提交回复
热议问题