Min-Width

用于设置页面元素的最小宽度的工具类

Class reference

Class Properties
.min-w-0 min-width: 0;
.min-w-full min-width: 100%;

用法

利用 min-w-0min-w-full 工具类设置页面元素的最小宽度。

min-w-full
<div class="w-24 min-w-full ...">
  min-w-full
</div>

响应式

如需控制页面元素在特定断点处的最小宽度,请在现有的 min-width 工具类的前面添加 {screen}: 前缀。

进一步了解 Tailwind 的响应式设计功能,请参阅 响应式设计 章节。

Target
Target
Target
Target
Target

定制

Min-width 比例

tailwind.config.js 配置文件中的 theme.minWidth 配置段可以定制 Tailwind 的默认 min-width 比例。

// tailwind.config.js
module.exports = {
theme: {
minWidth: {
+     '0': '0',
+     '1/4': '25%',
+     '1/2': '50%',
+     '3/4': '75%',
+     'full': '100%',
}
}
}

前往 定制主题 章节进一步了解定制默认主题的详细信息。

Responsive and pseudo-class variants

By default, only responsive variants are generated for min-width utilities.

You can control which variants are generated for the min-width utilities by modifying the minWidth property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

// tailwind.config.js
module.exports = {
variants: {
    // ...
-   minWidth: ['responsive'],
+   minWidth: ['responsive', 'hover', 'focus'],
}
}

Disabling

If you don't plan to use the min-width utilities in your project, you can disable them entirely by setting the minWidth property to false in the corePlugins section of your config file:

// tailwind.config.js
module.exports = {
corePlugins: {
    // ...
+   minWidth: false,
}
}