- 入门
- 核心概念
- 定制
- Base Styles
- 布局
- Flexbox & Grid
- Flex Basis
- Flex Direction
- Flex Wrap
- Flex
- Flex Grow
- Flex Shrink
- Order
- Grid Template Columns
- Grid Column Start / End
- Grid Template Rows
- Grid Row Start / End
- Grid Auto Flow
- Grid Auto Columns
- Grid Auto Rows
- Gap
- Justify Content
- Justify Items
- Justify Self
- Align Content
- Align Items
- Align Self
- Place Content
- Place Items
- Place Self
- 间隔
- 尺寸
- 排版
- Font Family
- Font Size
- Font Smoothing
- Font Style
- Font Weight
- Font Variant Numeric
- Letter Spacing
- Line Clamp
- Line Height
- List Style Image
- List Style Position
- List Style Type
- Text Align
- Text Color
- Text Decoration
- Text Decoration Color
- Text Decoration Style
- Text Decoration Thickness
- Text Underline Offset
- Text Transform
- Text Overflow
- Text Wrap
- Text Indent
- Vertical Align
- Whitespace
- Word Break
- Hyphens
- Content
- 背景
- 边框
- Effects
- Filters
- 表格 Tables
- Transitions & Animation
- Transforms
- Interactivity
- SVG
- Accessibility
- 其他
- Install Tailwind CSS using PostCSS
- Framework Guides
- Try Tailwind CSS using the Play CDN
- Install Tailwind CSS with Next.js
- Install Tailwind CSS with Laravel
- Install Tailwind CSS with Vite
- Install Tailwind CSS with Nuxt
- Install Tailwind CSS with Gatsby
- Install Tailwind CSS with SolidJS
- Install Tailwind CSS with SvelteKit
- Install Tailwind CSS with Angular
- Install Tailwind CSS with Ruby on Rails
- Install Tailwind CSS with Remix
- Install Tailwind CSS with Phoenix
- Install Tailwind CSS with Parcel
- Install Tailwind CSS with Symfony
- Install Tailwind CSS with Meteor
- Install Tailwind CSS with Create React App
- Install Tailwind CSS with Adonis
- Install Tailwind CSS With Ember.js
- Install Tailwind CSS with Astro
- Install Tailwind CSS with Qwik
- Install Tailwind CSS with Rspack
Font Variant Numeric
Utilities for controlling the variant of numbers.
Quick reference
Class | Properties |
---|---|
normal-nums | font-variant-numeric: normal; |
ordinal | font-variant-numeric: ordinal; |
slashed-zero | font-variant-numeric: slashed-zero; |
lining-nums | font-variant-numeric: lining-nums; |
oldstyle-nums | font-variant-numeric: oldstyle-nums; |
proportional-nums | font-variant-numeric: proportional-nums; |
tabular-nums | font-variant-numeric: tabular-nums; |
diagonal-fractions | font-variant-numeric: diagonal-fractions; |
stacked-fractions | font-variant-numeric: stacked-fractions; |
Basic usage
Applying numeric variants
Use the font-variant-numeric
utilities to enable additional glyphs for numbers, fractions, and ordinal markers (in fonts that support them).
These utilities are composable so you can enable multiple font-variant-numeric
features by combining multiple classes in your HTML:
<p class="ordinal slashed-zero tabular-nums ...">
1234567890
</p>
Note that many fonts don’t support these features (stacked fractions support for example is especially rare), so some of these utilities may have no effect depending on the font family you are using.
Ordinal
Use the ordinal
utility to enable special glyphs for the ordinal markers.
1st
<p class="ordinal ...">1st</p>
Slashed Zero
Use the slashed-zero
utility to force a 0 with a slash; this is useful when a clear distinction between O and 0 is needed.
0
<p class="slashed-zero ...">0</p>
Lining figures
Use the lining-nums
utility to use the numeric glyphs that are all aligned by their baseline. This corresponds to the lnum
OpenType feature. This is the default for most fonts.
1234567890
<p class="lining-nums ...">
1234567890
</p>
Oldstyle figures
Use the oldstyle-nums
utility to use numeric glyphs where some numbers have descenders. This corresponds to the onum
OpenType feature.
1234567890
<p class="oldstyle-nums ...">
1234567890
</p>
Proportional figures
Use the proportional-nums
utility to use numeric glyphs that have proportional widths (rather than uniform/tabular). This corresponds to the pnum
OpenType feature.
12121
90909
<p class="proportional-nums ...">
12121
</p>
<p class="proportional-nums ...">
90909
</p>
Tabular figures
Use the tabular-nums
utility to use numeric glyphs that have uniform/tabular widths (rather than proportional). This corresponds to the tnum
OpenType feature.
12121
90909
<p class="tabular-nums ...">
12121
</p>
<p class="tabular-nums ...">
90909
</p>
Diagonal fractions
Use the diagonal-fractions
utility to replace numbers separated by a slash with common diagonal fractions. This corresponds to the frac
OpenType feature.
1/2 3/4 5/6
<p class="diagonal-fractions ...">
1/2 3/4 5/6
</p>
Stacked fractions
Use the stacked-fractions
utility to replace numbers separated by a slash with common stacked fractions. This corresponds to the afrc
OpenType feature. Very few fonts seem to support this feature — we’ve used Ubuntu Mono here.
1/2 3/4 5/6
<p class="stacked-fractions ...">
1/2 3/4 5/6
</p>
Resetting numeric font variants
Use the normal-nums
property to reset numeric font variants. This is usually useful for resetting a font feature at a particular breakpoint:
<p class="slashed-zero tabular-nums md:normal-nums ...">
12345
</p>
Applying conditionally
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:tabular-nums
to only apply the tabular-nums
utility on hover.
<p class="proportional-nums hover:tabular-nums">
<!-- ... -->
</p>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
Breakpoints and media queries
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:tabular-nums
to apply the tabular-nums
utility at only medium screen sizes and above.
<p class="proportional-nums md:tabular-nums">
<!-- ... -->
</p>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论