【问题标题】:Can we really fill anything we want in transition-property CSS?我们真的可以在过渡属性 CSS 中填充任何我们想要的东西吗?
【发布时间】:2018-06-26 09:57:05
【问题描述】:

我刚刚意识到我们可以在transition-property CSS 参数后面添加任何我们想要的值,因为我只是这样做了(不是故意的)。然后我去了see the MDN docs,我们可以填写任何自定义值:

/* <custom-ident> values */
transition-property: test_05;
transition-property: -specific;
transition-property: sliding-vertically;

/* Multiple values */
transition-property: test1, animation4;
transition-property: all, height, all;
transition-property: all, -moz-specific, sliding;

所以我想知道:test1animation4 都不是有效的 CSS 属性,如果不是属性,可以在 transition-property 中传递什么样的值?关键帧?还有什么?

[编辑]:我添加了 MDN 给出的多个值的示例,其中一些 transition-property 没有填充有效的 CSS 属性。

【问题讨论】:

标签: css css-transitions transition


【解决方案1】:

如果我们继续阅读,您会看到如下不同的值:

没有属性会转换。

全部

所有可以转换的属性都会。

&lt;custom-ident&gt;

标识属性的字符串,当其值更改时应应用过渡效果。

所以是的,你可以在这里放你想要的东西,&lt;custom-indent&gt; 背后的想法是避免指定所有可用属性的详尽列表。因此,如果将来添加了新属性,它将保持有效,我们不必更改它。

如果您输入 random_58468 之类的内容,它将是一个有效值,您不会收到警告,但当然不会发生任何事情,因为没有名为 random_58468 的属性。

【讨论】:

  • 是的,但顺便说一句:transition-property: test1, animation4; transition-property: all, height, all; transition-property: all, -moz-specific, sliding; test1animation4 不是属性,为什么 MDN 也给出这个例子?
  • @arnaudambro 和我说的完全一样 :) 你可以放你想要的,transition 不在乎..它们都是有效的,但你根本没有效果。
  • 好吧,我觉得 MDN 把一些没有效果的值不大声说出来就很奇怪!谢谢@TemaniAfif
猜你喜欢
  • 1970-01-01
  • 2021-11-08
  • 1970-01-01
  • 2018-03-08
  • 1970-01-01
  • 2016-11-05
  • 1970-01-01
  • 1970-01-01
  • 2021-09-23
相关资源
最近更新 更多