HTML+CSS 中的不确定进度条
我想创建一个不确定的 HTML+CSS 进度条,使其看起来像 Vista 上的进度条:
(来源:microsoft.com)
我会喜欢:
- 水平调整进度条宽度(可以定义最小和最大宽度)
- 不要使用Javascript,而只是动画GIF,
- 在整个宽度上只有一个移动指示器有
什么建议如何做到这一点?
I would like to create an indeterminate HTML+CSS progress bar so it looks like the one on Vista:
(source: microsoft.com)
I would like to:
- horizontally adjust it to progress bar width (minimum and maximum width may be defined)
- don't use Javascript but rather just animated GIF
- having only one moving indicator on the whole width
Any suggestions how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,不,不!这是可能的
使用 CSS
overflow:hidden
和keyframe
,这是可能的。对于关键帧,我使用了从
left:-120px
(发光对象的宽度)到left:100%
我使用的结构:< s>
使用
:before
和:after
更新的紧凑结构:渐变、遮罩、发光和所有效果都需要昂贵的结构。如果有人有更好的主意,请告诉我。
目前,仅 webkit 解决方案(发光的椭圆遮罩):为 Firefox 和其他不支持
-webkit-mask-image 的浏览器添加了 SVG 遮罩
: http://jsfiddle.net/danvim/8M24k/NO, NO, NO! It is possible
Using CSS
overflow: hidden
andkeyframe
, it can be possible.For the keyframe, I used from
left:-120px
(width of the glowing object) toleft:100%
The structure I used:The updated, compact structure using
:before
and:after
:The gradient, masking, glowing and all the effects cost an expensive structure. If anyone has a better idea, please let me know.
At this date, webkit only solution(the ellipse mask for the glow):Added SVG mask for Firefox and other browsers that do not support
-webkit-mask-image
: http://jsfiddle.net/danvim/8M24k/:javascript 或 html5最简单的方法:javascript(喜欢与否...;))
The easiest way: javascript (like it or not... ;) )
仅 GIF 的解决方案
Vista 的不确定进度条在右侧消失后不会立即循环...
所以我可以创建一个足够宽的 GIF 图像,当进度条变窄时,它需要更长的时间来循环,当它变宽时,它会再次循环。 :)
在两种情况下,每次重复的时间是相同的,但在窄条中,到达终点所需的时间比在宽条中要少。
GIF-only solution
Vista's indeterminate progress bar doesn't loop right after it goes off on the right...
So I could create a wide enough GIF image and when progress bar would be narrow it would take longer for it to loop and when it'd be wider it loops again sonner. :)
Time of each repeat is the same in both cases but in narrow bar it takes less to get to the end than on the wider ones.