- 入门
- 核心概念
- 定制
- 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
Border Spacing
Utilities for controlling the spacing between table borders.
Quick reference
Class | Properties |
---|---|
border-spacing-0 | border-spacing: 0px 0px; |
border-spacing-x-0 | border-spacing: 0px var(--tw-border-spacing-y); |
border-spacing-y-0 | border-spacing: var(--tw-border-spacing-x) 0px; |
border-spacing-px | border-spacing: 1px 1px; |
border-spacing-x-px | border-spacing: 1px var(--tw-border-spacing-y); |
border-spacing-y-px | border-spacing: var(--tw-border-spacing-x) 1px; |
border-spacing-0.5 | border-spacing: 0.125rem 0.125rem; |
border-spacing-x-0.5 | border-spacing: 0.125rem var(--tw-border-spacing-y); |
border-spacing-y-0.5 | border-spacing: var(--tw-border-spacing-x) 0.125rem; |
border-spacing-1 | border-spacing: 0.25rem 0.25rem; |
border-spacing-x-1 | border-spacing: 0.25rem var(--tw-border-spacing-y); |
border-spacing-y-1 | border-spacing: var(--tw-border-spacing-x) 0.25rem; |
border-spacing-1.5 | border-spacing: 0.375rem 0.375rem; |
border-spacing-x-1.5 | border-spacing: 0.375rem var(--tw-border-spacing-y); |
border-spacing-y-1.5 | border-spacing: var(--tw-border-spacing-x) 0.375rem; |
border-spacing-2 | border-spacing: 0.5rem 0.5rem; |
border-spacing-x-2 | border-spacing: 0.5rem var(--tw-border-spacing-y); |
border-spacing-y-2 | border-spacing: var(--tw-border-spacing-x) 0.5rem; |
border-spacing-2.5 | border-spacing: 0.625rem 0.625rem; |
border-spacing-x-2.5 | border-spacing: 0.625rem var(--tw-border-spacing-y); |
border-spacing-y-2.5 | border-spacing: var(--tw-border-spacing-x) 0.625rem; |
border-spacing-3 | border-spacing: 0.75rem 0.75rem; |
border-spacing-x-3 | border-spacing: 0.75rem var(--tw-border-spacing-y); |
border-spacing-y-3 | border-spacing: var(--tw-border-spacing-x) 0.75rem; |
border-spacing-3.5 | border-spacing: 0.875rem 0.875rem; |
border-spacing-x-3.5 | border-spacing: 0.875rem var(--tw-border-spacing-y); |
border-spacing-y-3.5 | border-spacing: var(--tw-border-spacing-x) 0.875rem; |
border-spacing-4 | border-spacing: 1rem 1rem; |
border-spacing-x-4 | border-spacing: 1rem var(--tw-border-spacing-y); |
border-spacing-y-4 | border-spacing: var(--tw-border-spacing-x) 1rem; |
border-spacing-5 | border-spacing: 1.25rem 1.25rem; |
border-spacing-x-5 | border-spacing: 1.25rem var(--tw-border-spacing-y); |
border-spacing-y-5 | border-spacing: var(--tw-border-spacing-x) 1.25rem; |
border-spacing-6 | border-spacing: 1.5rem 1.5rem; |
border-spacing-x-6 | border-spacing: 1.5rem var(--tw-border-spacing-y); |
border-spacing-y-6 | border-spacing: var(--tw-border-spacing-x) 1.5rem; |
border-spacing-7 | border-spacing: 1.75rem 1.75rem; |
border-spacing-x-7 | border-spacing: 1.75rem var(--tw-border-spacing-y); |
border-spacing-y-7 | border-spacing: var(--tw-border-spacing-x) 1.75rem; |
border-spacing-8 | border-spacing: 2rem 2rem; |
border-spacing-x-8 | border-spacing: 2rem var(--tw-border-spacing-y); |
border-spacing-y-8 | border-spacing: var(--tw-border-spacing-x) 2rem; |
border-spacing-9 | border-spacing: 2.25rem 2.25rem; |
border-spacing-x-9 | border-spacing: 2.25rem var(--tw-border-spacing-y); |
border-spacing-y-9 | border-spacing: var(--tw-border-spacing-x) 2.25rem; |
border-spacing-10 | border-spacing: 2.5rem 2.5rem; |
border-spacing-x-10 | border-spacing: 2.5rem var(--tw-border-spacing-y); |
border-spacing-y-10 | border-spacing: var(--tw-border-spacing-x) 2.5rem; |
border-spacing-11 | border-spacing: 2.75rem 2.75rem; |
border-spacing-x-11 | border-spacing: 2.75rem var(--tw-border-spacing-y); |
border-spacing-y-11 | border-spacing: var(--tw-border-spacing-x) 2.75rem; |
border-spacing-12 | border-spacing: 3rem 3rem; |
border-spacing-x-12 | border-spacing: 3rem var(--tw-border-spacing-y); |
border-spacing-y-12 | border-spacing: var(--tw-border-spacing-x) 3rem; |
border-spacing-14 | border-spacing: 3.5rem 3.5rem; |
border-spacing-x-14 | border-spacing: 3.5rem var(--tw-border-spacing-y); |
border-spacing-y-14 | border-spacing: var(--tw-border-spacing-x) 3.5rem; |
border-spacing-16 | border-spacing: 4rem 4rem; |
border-spacing-x-16 | border-spacing: 4rem var(--tw-border-spacing-y); |
border-spacing-y-16 | border-spacing: var(--tw-border-spacing-x) 4rem; |
border-spacing-20 | border-spacing: 5rem 5rem; |
border-spacing-x-20 | border-spacing: 5rem var(--tw-border-spacing-y); |
border-spacing-y-20 | border-spacing: var(--tw-border-spacing-x) 5rem; |
border-spacing-24 | border-spacing: 6rem 6rem; |
border-spacing-x-24 | border-spacing: 6rem var(--tw-border-spacing-y); |
border-spacing-y-24 | border-spacing: var(--tw-border-spacing-x) 6rem; |
border-spacing-28 | border-spacing: 7rem 7rem; |
border-spacing-x-28 | border-spacing: 7rem var(--tw-border-spacing-y); |
border-spacing-y-28 | border-spacing: var(--tw-border-spacing-x) 7rem; |
border-spacing-32 | border-spacing: 8rem 8rem; |
border-spacing-x-32 | border-spacing: 8rem var(--tw-border-spacing-y); |
border-spacing-y-32 | border-spacing: var(--tw-border-spacing-x) 8rem; |
border-spacing-36 | border-spacing: 9rem 9rem; |
border-spacing-x-36 | border-spacing: 9rem var(--tw-border-spacing-y); |
border-spacing-y-36 | border-spacing: var(--tw-border-spacing-x) 9rem; |
border-spacing-40 | border-spacing: 10rem 10rem; |
border-spacing-x-40 | border-spacing: 10rem var(--tw-border-spacing-y); |
border-spacing-y-40 | border-spacing: var(--tw-border-spacing-x) 10rem; |
border-spacing-44 | border-spacing: 11rem 11rem; |
border-spacing-x-44 | border-spacing: 11rem var(--tw-border-spacing-y); |
border-spacing-y-44 | border-spacing: var(--tw-border-spacing-x) 11rem; |
border-spacing-48 | border-spacing: 12rem 12rem; |
border-spacing-x-48 | border-spacing: 12rem var(--tw-border-spacing-y); |
border-spacing-y-48 | border-spacing: var(--tw-border-spacing-x) 12rem; |
border-spacing-52 | border-spacing: 13rem 13rem; |
border-spacing-x-52 | border-spacing: 13rem var(--tw-border-spacing-y); |
border-spacing-y-52 | border-spacing: var(--tw-border-spacing-x) 13rem; |
border-spacing-56 | border-spacing: 14rem 14rem; |
border-spacing-x-56 | border-spacing: 14rem var(--tw-border-spacing-y); |
border-spacing-y-56 | border-spacing: var(--tw-border-spacing-x) 14rem; |
border-spacing-60 | border-spacing: 15rem 15rem; |
border-spacing-x-60 | border-spacing: 15rem var(--tw-border-spacing-y); |
border-spacing-y-60 | border-spacing: var(--tw-border-spacing-x) 15rem; |
border-spacing-64 | border-spacing: 16rem 16rem; |
border-spacing-x-64 | border-spacing: 16rem var(--tw-border-spacing-y); |
border-spacing-y-64 | border-spacing: var(--tw-border-spacing-x) 16rem; |
border-spacing-72 | border-spacing: 18rem 18rem; |
border-spacing-x-72 | border-spacing: 18rem var(--tw-border-spacing-y); |
border-spacing-y-72 | border-spacing: var(--tw-border-spacing-x) 18rem; |
border-spacing-80 | border-spacing: 20rem 20rem; |
border-spacing-x-80 | border-spacing: 20rem var(--tw-border-spacing-y); |
border-spacing-y-80 | border-spacing: var(--tw-border-spacing-x) 20rem; |
border-spacing-96 | border-spacing: 24rem 24rem; |
border-spacing-x-96 | border-spacing: 24rem var(--tw-border-spacing-y); |
border-spacing-y-96 | border-spacing: var(--tw-border-spacing-x) 24rem; |
Basic usage
Setting the border spacing
Use the border-spacing-*
, border-spacing-x-*
, and border-spacing-y-*
utilities to control the space between the borders of table cells with separate borders.
State | City |
---|---|
Indiana | Indianapolis |
Ohio | Columbus |
Michigan | Detroit |
<table class="border-separate border-spacing-2 border border-slate-400 ...">
<thead>
<tr>
<th class="border border-slate-300 ...">State</th>
<th class="border border-slate-300 ...">City</th>
</tr>
</thead>
<tbody>
<tr>
<td class="border border-slate-300 ...">Indiana</td>
<td class="border border-slate-300 ...">Indianapolis</td>
</tr>
<tr>
<td class="border border-slate-300 ...">Ohio</td>
<td class="border border-slate-300 ...">Columbus</td>
</tr>
<tr>
<td class="border border-slate-300 ...">Michigan</td>
<td class="border border-slate-300 ...">Detroit</td>
</tr>
</tbody>
</table>
Applying conditionally
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:border-spacing-2
to only apply the border-spacing-2
utility on hover.
<table class="hover:border-spacing-2">
<!-- ... -->
</table>
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:border-spacing-4
to apply the border-spacing-4
utility at only medium screen sizes and above.
<table class="md:border-spacing-4">
<!-- ... -->
</table>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
Using custom values
Customizing your theme
By default, Tailwind’s border spacing utilities use the default spacing scale. You can customize your spacing scale by editing theme.spacing
or theme.extend.spacing
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
spacing: {
'13': '3.25rem',
}
}
}
}
Alternatively, you can customize just the border spacing scale by editing theme.borderSpacing
or theme.extend.borderSpacing
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
borderSpacing: {
'13': '3.25rem',
},
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
Arbitrary values
If you need to use a one-off border-spacing
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<div class="border-spacing-[7px]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论