- 入门
- 核心概念
- 定制
- 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
Flex Basis
Utilities for controlling the initial size of flex items.
Quick reference
Class | Properties |
---|---|
basis-0 | flex-basis: 0px; |
basis-1 | flex-basis: 0.25rem; /* 4px */ |
basis-2 | flex-basis: 0.5rem; /* 8px */ |
basis-3 | flex-basis: 0.75rem; /* 12px */ |
basis-4 | flex-basis: 1rem; /* 16px */ |
basis-5 | flex-basis: 1.25rem; /* 20px */ |
basis-6 | flex-basis: 1.5rem; /* 24px */ |
basis-7 | flex-basis: 1.75rem; /* 28px */ |
basis-8 | flex-basis: 2rem; /* 32px */ |
basis-9 | flex-basis: 2.25rem; /* 36px */ |
basis-10 | flex-basis: 2.5rem; /* 40px */ |
basis-11 | flex-basis: 2.75rem; /* 44px */ |
basis-12 | flex-basis: 3rem; /* 48px */ |
basis-14 | flex-basis: 3.5rem; /* 56px */ |
basis-16 | flex-basis: 4rem; /* 64px */ |
basis-20 | flex-basis: 5rem; /* 80px */ |
basis-24 | flex-basis: 6rem; /* 96px */ |
basis-28 | flex-basis: 7rem; /* 112px */ |
basis-32 | flex-basis: 8rem; /* 128px */ |
basis-36 | flex-basis: 9rem; /* 144px */ |
basis-40 | flex-basis: 10rem; /* 160px */ |
basis-44 | flex-basis: 11rem; /* 176px */ |
basis-48 | flex-basis: 12rem; /* 192px */ |
basis-52 | flex-basis: 13rem; /* 208px */ |
basis-56 | flex-basis: 14rem; /* 224px */ |
basis-60 | flex-basis: 15rem; /* 240px */ |
basis-64 | flex-basis: 16rem; /* 256px */ |
basis-72 | flex-basis: 18rem; /* 288px */ |
basis-80 | flex-basis: 20rem; /* 320px */ |
basis-96 | flex-basis: 24rem; /* 384px */ |
basis-auto | flex-basis: auto; |
basis-px | flex-basis: 1px; |
basis-0.5 | flex-basis: 0.125rem; /* 2px */ |
basis-1.5 | flex-basis: 0.375rem; /* 6px */ |
basis-2.5 | flex-basis: 0.625rem; /* 10px */ |
basis-3.5 | flex-basis: 0.875rem; /* 14px */ |
basis-1/2 | flex-basis: 50%; |
basis-1/3 | flex-basis: 33.333333%; |
basis-2/3 | flex-basis: 66.666667%; |
basis-1/4 | flex-basis: 25%; |
basis-2/4 | flex-basis: 50%; |
basis-3/4 | flex-basis: 75%; |
basis-1/5 | flex-basis: 20%; |
basis-2/5 | flex-basis: 40%; |
basis-3/5 | flex-basis: 60%; |
basis-4/5 | flex-basis: 80%; |
basis-1/6 | flex-basis: 16.666667%; |
basis-2/6 | flex-basis: 33.333333%; |
basis-3/6 | flex-basis: 50%; |
basis-4/6 | flex-basis: 66.666667%; |
basis-5/6 | flex-basis: 83.333333%; |
basis-1/12 | flex-basis: 8.333333%; |
basis-2/12 | flex-basis: 16.666667%; |
basis-3/12 | flex-basis: 25%; |
basis-4/12 | flex-basis: 33.333333%; |
basis-5/12 | flex-basis: 41.666667%; |
basis-6/12 | flex-basis: 50%; |
basis-7/12 | flex-basis: 58.333333%; |
basis-8/12 | flex-basis: 66.666667%; |
basis-9/12 | flex-basis: 75%; |
basis-10/12 | flex-basis: 83.333333%; |
basis-11/12 | flex-basis: 91.666667%; |
basis-full | flex-basis: 100%; |
Basic usage
Setting the flex 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>
Applying conditionally
Hover, focus, and other states
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.
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: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
The default flex basis scale is a combination of the default spacing scale as well as a set of percentage based values.
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',
}
}
}
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论