How to apply css to only numbers in a text inside/or any lt;pgt;lt;pgt; element?(如何将css仅应用于文本内部/或任何lt;pgt;lt;pgt;中的数字元素?)
问题描述
我在我的网站中使用区域语言 unicode 字体,但数字看起来不太好.
I am Using a Regional language unicode font-face in my site but the numbers are not looking good.
所以我只想将新的字体样式或 css 应用于数字..
So I want to apply new font-style or css to numbers only..
请帮忙
推荐答案
这可以使用 CSS 的 unicode-range
属性,存在于 @font-face
中.
This can be done using CSS's unicode-range
property which exists within @font-face
.
数字 0 到 9 在 Unicode 中存在于 U+0030代码> 到
U+0039
.因此,您需要在现有字体旁边添加一个专门针对此范围的字体:
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;
}
这样做的结果是,Unicode 字符 U+0030
(0) 到 U+0039
(9) 的每个实例都将显示为专门针对该范围,并且所有其他字符都将使用您当前的字体.
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.
这篇关于如何将css仅应用于文本内部/或任何<p><p>中的数字元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将css仅应用于文本内部/或任何<p><p>中的数字元素?


基础教程推荐
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01