Related recommendations: "bootstrap Tutorial"
In web pages, the effects of progress bars are not uncommon, such as: bisection system, loading status Etc., the progress bar component uses the transition and animation attributes of CSS3 to complete some special effects. These special effects are not supported in IE9 and below versions, and older versions of Firefox. Opera 12 does not support the animation attribute.
The progress bar is the same as other independent components. Developers can choose the corresponding version according to their own needs:
LESS: progress-bars.less
SASS: _progress-bars .scss
Basic progress bar
Implementation principle:
Requires two containers. The container uses the class name .progress, and the sub-container uses the class name .progress-bar; .progress is used to set the background color, height, spacing, etc. of the progress bar container; and .progress-bar sets the progress direction and background of the progress bar. Color and transition effects; the following is the css source code:
.progress { height: 20px; margin-bottom: 20px; overflow: hidden; background-color: #f5f5f5; border-radius: 4px; -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); }
.progress-bar { float: left; width: 0; height: 100%; font-size: 12px; line-height: 20px; color: #fff; text-align: center; background-color: #428bca; -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); -webkit-transition: width .6s ease; transition: width .6s ease; }
Example:
role attribute role: tell search engines this p The function of the attribute is a progress bar;
aria-valuenow=”30” attribute effect: the progress of the current progress bar is 40%;
aria-valuemin=”0” attribute effect: the progress bar The minimum value is 0%;
aria-valuemax=”100” attribute function: the maximum value of the progress bar is 100%;
You can set the of the .sr-only class ;the label is removed from progress bar component and current displayed;< p>>
##Colored progress bar
Colored progress The bar is the same as the warning progress bar. In order to give the user a better experience, different progress bar colors are configured according to different statuses, mainly including the following four types: progress-bar-info: Indicates information Progress bar, blue progress-bar-success: indicates success progress bar, green progress-bar-warning: indicates warning progress bar, yellow progress-bar -danger: indicates error progress bar, red css source code:.progress-bar-success { background-color: #5cb85c; } .progress-bar-info { background-color: #5bc0de; } .progress-bar-warning { background-color: #f0ad4e; } .progress-bar-danger { background-color: #d9534f; }
彩色进度条
##Stripe progress barThe striped progress bar is implemented using the linear gradient of CSS3 without using any pictures. To use the striped progress bar, just add the class name "progress-striped" to the container.progress of the progress bar. If you want the progress stripe to look like colored progress The same, with color effects, just add the corresponding color class name to the progress bar
The following is the .progress-striped style source code:
.progress-striped .progress-bar { background-Learn more about the progress bar component in Bootstrap: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-Learn more about the progress bar component in Bootstrap:linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-size: 40px 40px; }
Each state corresponding to the striped progress also has a different Color
.progress-striped .progress-bar-success { background-Learn more about the progress bar component in Bootstrap: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-Learn more about the progress bar component in Bootstrap:linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); } .progress-striped .progress-bar-info { background-Learn more about the progress bar component in Bootstrap: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-Learn more about the progress bar component in Bootstrap:linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); } .progress-striped .progress-bar-warning { background-Learn more about the progress bar component in Bootstrap: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-Learn more about the progress bar component in Bootstrap:linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); } .progress-striped .progress-bar-danger { background-Learn more about the progress bar component in Bootstrap: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); background-Learn more about the progress bar component in Bootstrap:linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); }
Let’s take a look at the application of striped progress bar:
条纹进度条
Dynamic striped progress bar
On the basis of the progress bar .progress and .progress-striped classes, adding the class name .active can realize the dynamic striped progress bar.
The implementation principle is mainly accomplished through CSS3 animation. First, a progress-bar-stripes animation is created through @keyframes. This animation mainly does one thing, which is to change the position of the background Learn more about the progress bar component in Bootstrap, which is the value of background-position. Because the striped progress bar is made through the linear gradient of CSS3, and linear-gradient implements the background Learn more about the progress bar component in Bootstrap in the corresponding background.
The following is the css source code:
@-webkit-keyframes progress-bar-stripes { from { background-position: 40px 0; } to { background-position: 0 0; } } @keyframes progress-bar-stripes { from { background-position: 40px 0; } to { background-position: 0 0; } }
@keyframes is just An animation effect is created. If we want the progress bar to really move, we need to call the animation "progress-bar-stripes" created by @keyframes in a certain way, and trigger the animation to take effect through an event. In the Bootstrap framework, add a class name "active" to the progress bar container "progress", and let the "progress-bar-stripes" animation take effect after the document is loaded.
The style code corresponding to the calling animation is as follows :
.progress.active .progress-bar { -webkit-animation: progress-bar-stripes 2s linear infinite; animation: progress-bar-stripes 2s linear infinite; }
Example:
动态条纹进度条
效果如下(由于是直接从网页上结果来的图,这里并看不到它的动态效果):
层叠进度条:
层叠进度可以将不容状态的进度条放在一起,按水平方式排列
例子:
除了层叠彩色进度条之外,还可以层叠条纹进度条,或者说条纹进度条和彩色进度条混合层叠,仅需要在“progress”容器中添加对应的进度条,同样要注意,层叠的进度条之和不能大于100%。
下面来看一个例子:
更多编程相关知识,请访问:编程视频!!
The above is the detailed content of Learn more about the progress bar component in Bootstrap. For more information, please follow other related articles on the PHP Chinese website!