How do I put character • ::before an element?
This question already has an answer here:
CSS :before
and :after
's content
accepts escaped Unicode HEX representation of a character.
Let's learn how to get to it:
We could use content: "•";
but since we were thought to avoid special characters in favor of their primitive Unicode representation so that we don't get caught in defining @charset "utf-8";
in stylesheets and saving as such. Let's find such HEX value!
Open up Developer console and write:
"•".charCodeAt(0) // 8226 ( base10 )
the above will yield 8226
which is the Decimal Numeric value we generally use in HTML like •
to get •. Almost there...
Now let's do:
"•".charCodeAt(0).toString(16) // "2022" ( base16 )
console.log(
"•".charCodeAt(0).toString(16)
)
You can use a tool like Entity Converter which will convert your dot to a CSS-exploitable entity: ::before { content: '2022'; }
::before { content: '2022'; }
. Make sure the font your are using has that character in its character set, or that you use a fallback font that supports that character. Also, make sure you are applying this to a specific element with a selector ( a
, .someclass
, etc.).
上一篇: 在选择器之前添加空白