CSS加载器/进度微调器材料角2+

时间:2018-06-08 13:54:48

标签: html css material-design angular-material2

我试图模仿角度材料中的loader/Progress spinner。到目前为止,我做了以下组件。但我不知道为什么短划线的长度没有变化。

body {
  background-color: white;
}

// demo-specific
.showbox {
position: absolute;
   
}
// end demo-specific

.loader {
  position: relative;
  margin: 0 auto;
  width: 100px;
  &:before {
    content: '';
    display: block;
    padding-top: 100%;
  }
}

.circular {
  animation: rotate 2s linear infinite;
  height: 100%;
  transform-origin: center center;
  width: 100%;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
}

.path {
  stroke-dasharray: 1, 200;
  stroke-dashoffset: 0;
  animation: dash 2s ease-in-out infinite;
  stroke-linecap: round;
  stroke: #0057e7;
}

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

@keyframes dash {
  0% {
    stroke-dasharray: 20, 200;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 100, 200;
    stroke-dashoffset: -35px;
  }
  100% {
    stroke-dasharray: 200, 200;
    stroke-dashoffset: -125px;
  }
}
    <div class="showbox">
          <div class="loader">
            <svg class="circular" viewBox="25 25 50 50">
                <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/>
              </svg>
          </div>
        </div>

1 个答案:

答案 0 :(得分:0)

对我来说问题看起来是直接从0%到50%,其中示例从0%转换到10%等等。只需包含0到50%之间的更多步骤。