过渡:缩放 VS 过渡:变换 VS 过渡:全部

问题描述 投票:0回答:1

我在 CSS 中应用多个变换函数 -scale() 和 translate(),并且希望仅将转换应用于 scale 属性,因此我尝试了下面的代码块:

input:focus + label, input:not(:placeholder-shown)  + label {
  transform: scale(0.8) translate(3px, -6px);
  transition: scale 0.2s ease-in;
}

但是,这没有任何效果。当我尝试以下方法时,我能够达到我想要的效果

input:focus + label, input:not(:placeholder-shown)  + label {
  transform: scale(0.8) translate(3px, -6px);
  transition: transform 0.2s ease-in;
}

我不明白,因为没有

transition: transform 0.2s ease-in
选择所有属性 - 缩放和平移?

当我尝试

transition: all 0.2s ease-in
时,这与我预期的
transition: transform 0.2s ease-in
有不同的效果。

简而言之,有人可以帮助我理解两者之间的区别吗?

transition: **scale** 0.2s ease-in
VS
transition: **transform** 0.2s ease-in
VS
transition: **all** 0.2s ease-in

非常感谢您花时间和精力回答问题

css css-transitions css-transforms
1个回答
0
投票

transition 中给出的单词定义了将随transition 改变的属性。

scale
不是一个属性(它是
transform
的值),所以什么也没有发生

transform
是一个属性,因此将应用定义到其中的所有修改(
scale
translate

all
表示过渡将应用于所有更改的属性。

我不确定“财产”这个词是否准确,但我想你已经明白我所说的了。

© www.soinside.com 2019 - 2024. All rights reserved.