Interactivity
Utilities for optimizing upcoming animations of elements that are expected to change.
Class | Styles |
---|---|
will-change-auto | will-change: auto; |
will-change-scroll | will-change: scroll-position; |
will-change-contents | will-change: contents; |
will-change-transform | will-change: transform; |
will-change-<custom-property> | will-change: var(<custom-property>); |
will-change-[<value>] | will-change: <value>; |
Use the will-change-scroll
, will-change-contents
and will-change-transform
utilities to optimize an element that's expected to change in the near future by instructing the browser to prepare the necessary animation before it actually begins:
<div class="overflow-auto will-change-scroll"> <!-- ... --></div>
It's recommended that you apply these utilities just before an element changes, and then remove it shortly after it finishes using will-change-auto
.
The will-change
property is intended to be used as a last resort when dealing with known performance problems. Avoid using these utilities too much, or simply in anticipation of performance issues, as it could actually cause the page to be less performant.
Use the will-change-[<value>]
syntax to set the will-change
property based on a completely custom value:
<div class="will-change-[top,left] ..."> <!-- ... --></div>
For CSS variables, you can also use the will-change-(<custom-property>)
syntax:
<div class="will-change-(--my-properties) ..."> <!-- ... --></div>
This is just a shorthand for will-change-[var(<custom-property>)]
that adds the var()
function for you automatically.
Tailwind CSS 中文网(本网站)的目标是为中文开发者提供准确、及时的 Tailwind CSS 中文文档
Tailwind CSS 中文文档由本网站维护人员共同翻译,采用 MIT 开源协议发布
本网站与 tailwindcss.com 及 Tailwind Labs Inc. 并无从属关系
Tailwind 商标由 Tailwind Labs Inc. 所有
京ICP备15031610号-8