Bootstrap 组件:进度条组件(progress)

本文介绍了Bootstrap的进度条组件,包括默认样式、带有提示标签、情境变化效果、条纹和动画效果,以及堆叠效果。通过CSS3的transition和animation属性实现动态效果,适用于不同场景的实时反馈。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

作者:WangMin
格言:努力做好自己喜欢的每一件事
优快云原创文章
博客地址 👉 WangMin

通过这些简单、灵活的进度条,为当前工作流程或动作提供实时反馈。

注意: 进度条组件使用了 CSS3 的 transition 和 animation 属性来完成一些特效。这些特性在 Internet Explorer 9 或以下版本中、Firefox 的老版本中没有被支持。Opera 12 不支持 animation 属性。

默认样式进度条

实现原理:需要两个容器,外容器使用类名.progress,子容器使用类名.progress-bar;其中.progress用来设置进度条容器的背景色,容器的高度,间距等;而.progress-bar设置进度方向,进度条的背景色和过度效果。

<div class="progress">
	<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;">
		<span class="sr-only">60% Complete</span>
	</div>
</div>

在这里插入图片描述


带有提示标签的进度条

将设置了.sr-only类的<span>标签从进度条组件中移除 类,从而让当前进度显示出来。

<div class="progress">
	<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;">
		<span>60% Complete</span>
	</div>
</div>

在这里插入图片描述

在展示很低的百分比时,如果需要让文本提示能够清晰可见,可以为进度条设置min-width属性。

<div class="progress">
	<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="min-width:20px;">
		<span>0% Complete
Bootstrap Progressbar 是一个 jQuery 插件,扩展了基本引导进度。它通过添加 Javascript 中预先存在的 CSS 转换提供了动态进度条。此外,你可以在动态进度条中通过回调显示当前进度信息。代码示例:default valuesProgressbar.defaults = {     transition_delay: 300,     refresh_speed: 50,     display_text: &#39;none&#39;,     use_percentage: true,    percent_format: function(percent) { return percent   &#39;%&#39;; },    amount_format: function(amount_part, amount_total) { return amount_part   &#39; / &#39;   amount_total; },     update: $.noop,     done: $.noop,     fail: $.noop };transition_delay$(document).ready(function() {     $(&#39;.progress .progress-bar&#39;).progressbar({         transition_delay: 1500     }); });animationhorizontalless.progress .bar {     .transition(width 2s ease-in-out); }scss.progress.vertical .progress-bar {     @include transition(width 2s ease-in-out); }css.progress .bar {     -webkit-transition: width 2s ease-in-out;     -moz-transition: width 2s ease-in-out;     -ms-transition: width 2s ease-in-out;     -o-transition: width 2s ease-in-out;     transition: width 2s ease-in-out; }verticalless.progress.vertical .bar {     .transition(height 2s ease-in-out); }scss.progress.vertical .bar {     @include transition(height 2s ease-in-out); }css.progress.vertical .bar {     -webkit-transition: height 2s ease-in-out;     -moz-transition: height 2s ease-in-out;     -ms-transition: height 2s ease-in-out;     -o-transition: height 2s ease-in-out;     transition: height 2s ease-in-out; } 标签:Bootstrap
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值