【问题标题】:css loading spinner not spinningCSS加载微调器不旋转
【发布时间】:2020-12-05 01:36:23
【问题描述】:

我正在尝试重新创建此微调器 here,但我似乎无法弄清楚它为什么不旋转。我对反应不好,所以我认为这可以通过纯 css 来实现。我已经把它的样式正确地设置了,但旋转没有运气。

<div class="Loading__StyledLoading bWDkpr">
  <svg viewBox="0 0 40 40" class="Loading__StyledSpinner dCPhrt">
    <circle cx="50%" cy="50%" r="18" type="pageLoader" class="Loading__StyledSpinnerCircle hsiYVK"></circle>
  </svg>
  <div type="pageLoader" class="Loading__StyledLoadingText dpesEv"></div>
</div>

css

.bWDkpr {
  height: 120px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  -webkit-box-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  align-items: center;
  overflow-x: hidden;
  overflow-y: hidden;
  box-sizing: border-box;
}

.dCPhrt {
  width: 40px;
  height: 40px;
  animation-duration: 0.75s;
  animation-timing-function: linear;
  animation-delay: initial;
  animation-iteration-count: infinite;
  animation-direction: initial;
  animation-fill-mode: initial;
  animation-play-state: initial;
  animation-name: cZxgpV;
}

.hsiYVK {
  fill: transparent;
  stroke: rgb(186, 199, 213);
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-dasharray: 128px;
  stroke-dashoffset: 64px;
}

感谢任何帮助。谢谢!

【问题讨论】:

    标签: css css-animations css-transitions


    【解决方案1】:

    您可以为transform 属性设置动画:

    .bWDkpr {
      height: 120px;
      padding-top: 12px;
      display: flex;
      flex-direction: column;
      -webkit-box-pack: center;
      justify-content: center;
      -webkit-box-align: center;
      align-items: center;
      overflow-x: hidden;
      overflow-y: hidden;
      box-sizing: border-box;
    }
    
    .dCPhrt {
      width: 40px;
      height: 40px;
      animation-duration: 0.75s;
      animation-timing-function: linear;
      animation-delay: initial;
      animation-iteration-count: infinite;
      animation-direction: initial;
      animation-fill-mode: initial;
      animation-play-state: initial;
      animation-name: cZxgpV;
    }
    
    .hsiYVK {
      fill: transparent;
      stroke: rgb(186, 199, 213);
      stroke-width: 3px;
      stroke-linecap: round;
      stroke-dasharray: 128px;
      stroke-dashoffset: 64px;
    }
    
    @keyframes cZxgpV {
      from {
        transform: rotate(360deg);
      }
    }
    <div class="Loading__StyledLoading bWDkpr">
      <svg viewBox="0 0 40 40" class="Loading__StyledSpinner dCPhrt">
        <circle cx="50%" cy="50%" r="18" type="pageLoader" class="Loading__StyledSpinnerCircle hsiYVK"></circle>
      </svg>
      <div type="pageLoader" class="Loading__StyledLoadingText dpesEv"></div>
    </div>

    【讨论】:

    • 完美。这帮了大忙。我明白我现在错过了什么。谢谢,丹尼尔!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-22
    • 1970-01-01
    • 2018-06-22
    • 1970-01-01
    • 1970-01-01
    • 2016-11-02
    相关资源
    最近更新 更多