概念
提前告诉浏览器要做什么动画,让其提前准备优化设置。
兼容性:
IE13+、FireFox47+、Chrome49+、Safari9.1+、Opera39+
语法
will-change: auto | scroll-position | contents | <custom-ident>
参数说明:
scroll-position:表示将要改变元素的滚动位置
contents:表示将要改变元素的内容
<custom-ident>
:明确制定将要改变的属性和给定的动画名称
建议使用contents
例如,transform将要改变:will-change:transform
特别提醒,Opera不需要加前缀。
使用注意
不要直接写在该元素上,最后写在父元素的hover上,这样移出的时候就会自动remove。
如果使用js添加will-change, 事件或动画完毕,一定要及时remove。