css - 如何增加刻度线动画的大小

标签 css animation svg sass

我想在我的网站上添加一个动画标记,但我想调整这个 tickmark 的大小到现在的 3-4 倍。

CSS:

.checkmark__circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: #7ac142;
  fill: none;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: block;
  stroke-width: 2;
  stroke: #fff;
  stroke-miterlimit: 10;
  margin: 10% auto;
  box-shadow: inset 0px 0px 0px #7ac142;
  animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}

.checkmark__check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}
@keyframes scale {
  0%, 100% {
    transform: none;
  }
  50% {
    transform: scale3d(1.1, 1.1, 1);
  }
}
@keyframes fill {
  100% {
    box-shadow: inset 0px 0px 0px 30px #7ac142;
  }
}

HTML:

<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
    <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
    <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
</svg>

我正在尝试增加它的大小,但能够增加外圆的大小,但无法增加刻度线的大小。请建议

最佳答案

只需更改 css,如下所示。

比较元素以了解已更改的内容。

// Colors
$green: #7ac142;
$white: #fff;

// Misc
$curve: cubic-bezier(0.650, 0.000, 0.450, 1.000);

body {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkmark {
  width: 156px;
  height: 156px;
  border-radius: 50%;
  display: block;
  stroke-width: 5;
  stroke: $white;
  stroke-miterlimit: 10;
  box-shadow: inset 0px 0px 0px $green;
  animation: fill .4s ease-in-out .4s forwards, scale .9s ease-in-out 1s both;
}

.checkmark__circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 5;
  stroke-miterlimit: 1;
  stroke: $green;
  fill: none;
  animation: stroke .6s $curve forwards;
}

.checkmark__check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke .3s $curve .8s forwards;
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes scale {
  0%, 100% {
    transform: none;
  }
  50% {
    transform: scale3d(0.1, 0.1, 0);
  }
}

@keyframes fill {
  100% {
    box-shadow: inset 0px 0px 0px 78px $green;
  }
}

关于css - 如何增加刻度线动画的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56196536/

相关文章:

清理 CSS 的 Javascript 解决方案

CSS - 将下拉菜单左、中、右对齐

swift - 线性 CABasicAnimation 在容器 View 中不是线性执行的

ios - SpriteKit Swift 动画一次只能在一个 Sprite 上 - iOS

css - 从背景中剪下的透明文本

javascript - ScrollMagic 插件正在运行,但不是 "tying"滚动动画

css - JQuery 自动完成主题框未正确放置

css - 边框顶部样式(线性渐变)

javascript - 在 THREEjs 中对对象的大小进行动画处理

css - 无法使用 Angular 将样式应用于组件 css 中的 svg,仅在全局 css 文件中