当单独指定的属性CSS动画的工作方式不同

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

我有以下的CSS动画两个独立的要素:

.loading-icon,
.loading-icon-2{
  height: 50px;
  position: relative;
  left: 50%;
  top: 30%;
  transform: translateXY(-50%, 50%);
}

.loading-icon {
  display: flex;
  border: 16px solid #f3f3f3; /* Light grey */
  border-top: 16px solid #3498db; /* Blue */
  border-radius: 50%;
  width: 60px;
  height: 60px;
  text-align: center;
  animation-name: spin;
  animation-duration: 2s;
  transition-timing-function: linear;
  animation-iteration-count: infinite;
  animation: spin 2s linear infinite;
}

.loading-icon-2 {
  display: flex;
  border: 16px solid #f3f3f3; /* Light grey */
  border-top: 16px solid #3498db; /* Blue */
  border-radius: 50%;
  width: 60px;
  height: 60px;
  text-align: center;
  animation-name: anotherspin;
  animation-duration: 2s;
  transition-timing-function: linear;
  animation-iteration-count: infinite;
}

.loading-icon div,
.loading-icon-2 div {
  margin: auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes anotherspin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

唯一的区别是,对于loading-icon-2类的所有动画属性已经指定使用速记风格的单独来代替。

但是,这两个元素表现不同。可能有人请帮助理解为什么发生这种情况还是我失去了一些东西。看到代码工作在这里CodePen

css css3 css-animations
1个回答
3
投票

不同的是,你使用transition-timing-function: linear代替animation-timing-function: linear的。当您使用速记,虽然,它含蓄地采用正确的属性名称,使动画看起来没有宽松持续。

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