如何将css仅应用于文本内部的数字/或任何<p> <p>元素?

Sin*_*jan 8 javascript css jquery fonts numbers

我在我的网站中使用区域语言unicode font-face,但数字看起来不太好.

所以我想将新的font-style或css应用于数字..

请帮忙

Jam*_*lly 15

This can be done using CSS's unicode-range property which exists within @font-face.

The numbers 0 to 9 exist in Unicode within the range U+0030 to U+0039. So what you'll need to do is include a font alongside your existing font which specifically targets this range:

@font-face { 
    font-family: 'My Pre-Existing Font';
    ...
}
@font-face {
    font-family: 'My New Font Which Handles Numbers Correctly';
    ...
    unicode-range: U+30-39;
}
Run Code Online (Sandbox Code Playgroud)

The result of this will be that every instance of Unicode characters U+0030 (0) through to U+0039 (9) will be displayed in the font which specifically targets that range, and every other character will be in your current font.


Lon*_*Dev 0

没有办法将 CSS 专门应用于所有数字。在每个数字标签中,您可以添加属性class='number',然后在 CSS 中添加

.number {
   font-family: arial;
}
Run Code Online (Sandbox Code Playgroud)