css实现网页滚动数字圆环进度条显示效果代码
代码语言:html
所属分类:进度条
代码描述:css实现网页滚动数字圆环进度条显示效果代码,滚动鼠标的滚轮来滚动网页,右侧显示进度条。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> /* REGISTER VAR TO BE ANIMATABLE*/ @property --percentage { initial-value: 0; inherits: false; syntax: '<number>'; } /* animating the custom prop*/ @keyframes updatePerc { to { --percentage: 100; } } :root { animation: updatePerc linear; animation-timeline: scroll(); /* create some custom props to derive different effects*/ --primary-color: hsl(calc(var(--percentage, 0) * 3.6), 45%, 56%); --angle: calc(var(--percentage, 0) * 3.6deg); --txt: calc(var(--percentage)); } /* Drawing the arc */ .progress:after { background: conic-gradient( var(--primary-color) var(--angle), transparent var(--angle) ); } /* Number as text */ .progress__txt:after { counter-reset: myCounter var(--txt); content: counter(myCounter) "%"; display: block; } /*COSMETIC*/ .progress { --borderWidth: 10px; --size: 8rem; border-radius:100%; width: var(--size); height: var(--size); margin: 60px auto; border: 1px solid white; position: fixed; display: flex; justify-content: center; align-items: center; top: 2rem; right: 2rem; z-index: 2; font-size: 2em; } .progress:before { border-radius: 100%; content: ''; width: calc(var(--size) - var(--borderWidth) ); height: calc(var(--size) - var(--borderWidth)); position: absolute; background: #222; z-index: 1; } .progress:after { border-radius: 100%; content: ''; position: absolute; top: calc(var(--borderWidth) / -2); left: calc(var(--borderWidth) / -2); width: calc(var(--size) + var(--borderWidth)); height: calc(var(--size) + var(--borderWidth)) } .progress__txt { z-index: 2; } /* GENERAL DOCUMENT COSMETIC */ main{ width: min(90%, 80ch); margin-inline: auto; } img { width: 100%; } body{ margin: 0; padding: 0; padding-top: 2rem; font-family: sans-serif; background: #222; color: #bbb; } h1 { width: 100%; position:sticky; top: 0; color: var(--primary-color); background: #222; font-size: 5em; line-height: 0.9; z-index: 1; padding-block: 2rem; margin-inline: -2em; padding-inline: 2em; } p{ line-height: 1.75; } </style> </head> <body translate="no"> <div class="progress"> <span class="progress__txt"></span> </div> <main> <h1>Circular reading progress</h1> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde labore maxime nostrum rerum cumque, soluta nisi impedit, ratione dolorem pariatur voluptates modi itaque. Possimus ul.........完整代码请登录后点击上方下载按钮下载查看
网友评论0