CSS“内容”中的 HTML 特殊字符属性

发布于 2024-10-08 08:55:40 字数 117 浏览 0 评论 0原文

我正在尝试使用 CSS :before + content: 字段在项目之前添加内容。我想插入一个复选标记 (☑),但如果我在内容选项中使用它,它会打印为文字。我如何告诉 CSS 使其成为复选标记,而不是文字字符串 ☑?

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 option, it prints as the literal. How can I tell CSS to make that a checkmark, not the literal string ☑?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾城泪 2024-10-15 08:55:40

试试这个:

#target:before {
  content: "\2611";
}

Try this:

#target:before {
  content: "\2611";
}
給妳壹絲溫柔 2024-10-15 08:55:40

您需要在 content 属性中使用 Unicode 值。 (杂项符号列表也可能有用。)

重勾标记列为 U+2713 所以你可以输入 content: "\2713";

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";

荒路情人 2024-10-15 08:55:40

在 CSS 规则中按字面意思使用复选框字符而不是编码 -

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

请参阅:http://jsfiddle.net/e3Wt2/

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文