Tailwind CSS v2.1

Adam Wathan

自 Tailwind CSS v2.0 以来的第一个新功能更新已经发布,并且包含许多很酷的功能!我们将新的 JIT 引擎合并到核心,添加了对可组合 CSS 滤镜的一级支持,添加了混合模式实用程序等等。

¥The first new feature update since Tailwind CSS v2.0 is here and loaded with lots of cool stuff! We've merged the new JIT engine to core, added first-class support for composable CSS filters, added blending mode utilities, and a bunch more.

以下是一些亮点:

¥Here are some of the highlights:

完整详情,请访问 GitHub 上的 check out the release notes

¥For the full details, check out the release notes on GitHub.


核心中的 JIT 引擎(JIT engine in core)

¥JIT engine in core

brand-new JIT engine we announced in March 现已合并到核心,并可作为可选功能使用,只需在 tailwind.config.js 文件中使用新的 mode 选项即可:

¥The brand-new JIT engine we announced in March has now been merged into core, and is available as an opt-in feature using a new mode option in your tailwind.config.js file:

module.exports = {
mode: "jit",
purge: [
// ...
],
// ...
};

此功能仍处于预览阶段,这意味着随着我们不断完善,一些细节可能会发生变化,并且它不受语义版本控制的影响。

¥This feature is still in preview which means some details may change as we iron out the kinks, and it's not subject to semantic versioning.

如果你之前使用的是 @tailwindcss/jit,现在可以迁移到 Tailwind CSS v2.1,因为引擎的所有新开发都将在此进行。

¥If you were using @tailwindcss/jit before, you can now migrate to Tailwind CSS v2.1 instead, as that's where all new development on the engine will happen.

阅读 Just-in-Time Mode documentation 了解更多信息。

¥Read the Just-in-Time Mode documentation to learn more.

可组合 CSS 滤镜 API(Composable CSS filters API)

¥Composable CSS filters API

这是一个重大更新 - 我们终于添加了对 CSS 滤镜的一流支持!

¥This is a huge one — we've finally added first-class support for CSS filters!

它们的工作原理与我们的 transform 实用程序非常相似,你可以使用 filter 启用滤镜,并将其与 grayscaleblur-lgsaturate-200 等实用程序结合使用,以动态组合滤镜。

¥They work a lot like our transform utilities, where you use filter to enable filters, and combine it with utilities like grayscale, blur-lg, or saturate-200 to compose filters on the fly.

<div class="blur-md grayscale invert filter ...">
<!-- ... -->
</div>

……backdrop-filter 的样子如下:

¥...and here's what backdrop-filter looks like:

<div class="backdrop-blur backdrop-brightness-50 backdrop-filter ...">
<!-- ... -->
</div>

查看 filterbackdrop-filter 了解更多信息。我们很快会在那里添加一些有用的可视化示例!

¥Check out the filter and backdrop-filter to learn more. We'll add a bunch of helpful visual examples there soon!

新的混合模式工具(New blending mode utilities)

¥New blending mode utilities

我们为 mix-blend-modebackground-blend-mode 添加了全新的实用程序:

¥We've added brand new utilities for mix-blend-mode and background-blend-mode:

<div class="mix-blend-multiply ...">
<!-- ... -->
</div>

查看 the documentation 了解更多信息。

¥Check out the documentation to learn more.

新的隔离工具(New isolation utilities)

¥New isolation utilities

我们添加了新的 isolateisolation-auto 实用程序,用于处理 isolation 属性:

¥We've added new isolate and isolation-auto utilities for working with the isolation property:

<div class="isolate ...">
<!-- ... -->
</div>

这对于确定混合模式功能或 z-index 调整的范围非常有用,并且非常强大。

¥This can be really helpful for scoping blending mode features or z-index adjustments and is super powerful.

查看 the documentation 了解更多信息。

¥Check out the documentation to learn more.

我也强烈推荐 this great article by Josh Comeau 来体验它的实际应用。

¥I also highly recommend this great article by Josh Comeau to see it in action.


升级(Upgrading)

¥Upgrading

Tailwind CSS v2.1 是一个增量升级,没有重大更改,因此要升级,你只需运行:

¥Tailwind CSS v2.1 is an incremental upgrade with no breaking changes, so to upgrade you just need to run:

npm install tailwindcss@latest

如果你之前使用的是 @tailwindcss/jit,现在可以切换回 tailwindcss 并相应地更新你的 PostCSS 配置。

¥If you were previously using @tailwindcss/jit, you can now switch back to tailwindcss and update your PostCSS configuration accordingly.

准备好升级了吗?Get it from npm →

¥Ready to upgrade? Get it from npm →

此迁移确保内容遵循新的 v4 格式,并使用示例、摘录和代码块中指定的组件和代码。

¥This migration ensures the content adheres to the new v4 format, utilizing the components and codes specified for examples, excerpts, and code blocks.

TailwindCSS v4.1 中文网 - 粤ICP备13048890号