【问题标题】:Can I specify the transform attribute in transition?我可以在过渡中指定变换属性吗?
【发布时间】:2019-01-08 17:57:39
【问题描述】:

最常见的情况是这样的:

    transition: background-color 0.2s,
                transform 1s;

但我想指定由过渡控制的转换属性,例如

transition: transform scale 1s,
            transform skew 0.5s,
            transform rotate 2s;

我试过了,没用。

【问题讨论】:

    标签: css css-transitions css-transforms


    【解决方案1】:

    使用animation 代替transition 并设置所有时间(1s+0.5s+2s)并在@keyframes 中将其划分为您要为每个transform 属性设置的时间

    div{
      width: 100px;
      height: 100px;
      background: red;
    }
    div:hover{
     animation: move 2.5s;
    }
        @keyframes move {
          0% {
            transform: scale(3);
          }
          35% {
            transform: scale(3) skew(180deg); 
          }
          50%{
           transform: scale(3) skew(180deg) rotate(70deg); 
          }
        }
    <div></div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-16
      • 2015-03-10
      • 2012-10-29
      • 1970-01-01
      • 2021-02-15
      • 2016-08-02
      • 2018-03-08
      相关资源
      最近更新 更多