弹性盒 & 网格
用于控制弹性项目初始大小的工具。
¥Basic usage
¥Setting the flex basis
使用 basis-*
工具设置弹性项目的初始大小。
¥Use the basis-*
utilities to set the initial size of flex items.
<div class="flex flex-row">
<div class="basis-1/4">01</div>
<div class="basis-1/4">02</div>
<div class="basis-1/2">03</div>
</div>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:basis-1/2
to only apply the basis-1/2
utility on hover.
<div class="basis-1/3 hover:basis-1/2">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:basis-1/3
to apply the basis-1/3
utility at only medium screen sizes and above.
<div class="flex flex-row">
<div class="basis-1/4 md:basis-1/3">01</div>
<div class="basis-1/4 md:basis-1/3">02</div>
<div class="basis-1/2 md:basis-1/3">03</div>
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
¥Using custom values
¥Customizing your theme
默认的 flex basis scale 是 默认间距比例 和一组基于百分比的值的组合。
¥The default flex basis scale is a combination of the default spacing scale as well as a set of percentage based values.
你可以通过编辑 tailwind.config.js
文件中的 theme.spacing
或 theme.extend.spacing
来自定义间距比例。
¥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: {
'112': '28rem',
'128': '32rem',
}
}
}
}
或者,你可以通过编辑 tailwind.config.js
文件中的 theme.flexBasis
或 theme.extend.flexBasis
来自定义弹性基础比例。
¥Alternatively, you can customize just the flex basis scale by editing theme.flexBasis
or theme.extend.flexBasis
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
flexBasis: {
'1/7': '14.2857143%',
'2/7': '28.5714286%',
'3/7': '42.8571429%',
'4/7': '57.1428571%',
'5/7': '71.4285714%',
'6/7': '85.7142857%',
}
}
}
}
在 主题定制 文档中了解有关自定义默认主题的更多信息。
¥Learn more about customizing the default theme in the theme customization documentation.
¥Arbitrary values
If you need to use a one-off flex-basis
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="basis-[14.2857143%]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.