[英]the 'animate()' function my code doesn't work but 'css()' does. what's wrong?
this piece of code works only when i write 这段代码仅在我编写时有效
.css()
, but not , 但不是
.animate()
What is the reason? 是什么原因?
the whole thing: 整个东西:
$(window).on("scroll", function () { $('.banner').animate({'background':'linear-gradient(to right, black 50%, white 50%'}, 800); $('.banner h1').animate({ 'background': 'linear-gradient(to left, black 50%, white 50%', '-webkit-background-clip': 'text', '-webkit-text-fill-color': 'transparent' }, 800)
From the documentation : 从文档中 :
All animated properties should be animated to a single numeric value, except as noted below;
除非另有说明,否则所有动画属性都应设置为单个数值。 most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color plugin is used).
大多数非数字属性不能使用基本的jQuery功能进行动画处理(例如,可以对width,height或left进行动画处理,但不能对background-color进行动画处理,除非使用jQuery.Color插件)。 Property values are treated as a number of pixels unless otherwise specified.
除非另有说明,否则属性值被视为像素数。 The units em and % can be specified where applicable.
可以在适当的地方指定单位em和%。
What you're trying to animate doesn't fit the description of what it says it can animate. 您要设置动画的内容与它可以设置动画的描述不符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.