svg在html中自定义圆环,前端 svg 如何 开发 圆环加载

/p>

<

.progress {

width: 9.55rem;

height: 9.55rem;

position: absolute;

top: 50%;

left: 50%;

margin: -4.77rem 0 0 -4.77rem

}

.percent {

position: absolute;

top: 50%;

left: 50%;

width: 5rem;

height: 4rem;

margin: -2rem 0 0 -2.5rem

}

.percent p {

color: #EB6200;

text-align: center;

font-size: 1.3rem

}

.percent h1,

.percent h2 {

text-align: center;

line-height: 1.2rem

}

.progress svg {

width: 9.55rem;

height: 9.55rem;

}

.progress svg path {

stroke: #EB6200;

stroke-width: 4;

opacity: 1;

fill: none;

-webkit-transition: stroke-dashoffset 0.3s;

transition: stroke-dashoffset 0.3s;

-webkit-animation: dash 2s linear forwards;

}

@-webkit-keyframes dash {

to {

stroke-dashoffset: 0;

}

}

100%

style=”stroke-dasharray: 204.243713378906px; stroke-dashoffset: 204.243713378906px;”>

(function (doc, win) {

var docEl = doc.documentElement,

resizeEvt = ‘orientationchange’ in window ? ‘orientationchange’ : ‘resize’,

recalc = function () {

var clientWidth = docEl.clientWidth;

if (!clientWidth) return;

docEl.style.fontSize = (20 * (clientWidth / 320)) > 40 ? 40 + “px” : (20 * (clientWidth / 320)) + ‘px’;

};

if (!doc.addEventListener) return;

win.addEventListener(resizeEvt, recalc, false);

doc.addEventListener(‘DOMContentLoaded’, recalc, false);

function percent() {

var i = document.querySelector(“.percent > p”),

time = 0,

interval = setInterval(function () {

time += 1;

i.innerHTML = time + “%”;

if (time >= 100) {

clearInterval(interval)

}

}, 20);

}

percent()

})(document, window);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的 SVG 科技感动画圆环的代码示例,您可以根据您的需求进行修改: ```html <svg width="200" height="200"> <circle cx="100" cy="100" r="80" fill="none" stroke="#0077be" stroke-width="10" stroke-dasharray="502.4" stroke-dashoffset="502.4"></circle> <circle cx="100" cy="100" r="80" fill="none" stroke="#00ffea" stroke-width="10" stroke-dasharray="502.4" stroke-dashoffset="0"> <animate attributeName="stroke-dashoffset" from="502.4" to="0" dur="2s" repeatCount="indefinite"></animate> </circle> </svg> ``` 解释一下上面代码的含义: - `cx` 和 `cy` 属性定义了圆的心点坐标。 - `r` 属性定义了圆的半径。 - `fill` 属性定义了圆的填充颜色,这里设置为 `none` 表示不填充。 - `stroke` 属性定义了圆的边框颜色。 - `stroke-width` 属性定义了圆的边框宽度。 - `stroke-dasharray` 属性定义了边框的样式,这里设置为 `502.4`,表示圆的周长。 - `stroke-dashoffset` 属性定义了边框的起始偏移量,这里设置为 `502.4`,表示圆的周长。这样圆环就被隐藏了。 - `<animate>` 标签用于定义动画,其 `attributeName` 属性定义了要进行动画的属性,这里设置为 `stroke-dashoffset`。`from` 属性定义了动画的起始值,这里设置为 `502.4`。`to` 属性定义了动画的结束值,这里设置为 `0`。`dur` 属性定义了动画的持续时间,这里设置为 `2s`。`repeatCount` 属性定义了动画的重复次数,这里设置为 `indefinite`,表示无限循环。 您可以根据需要修改上述代码的颜色、宽度、动画时间等属性,以达到您想要的效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值