html 纵向进度条,垂直CSS / HTML5进度条(Vertical CSS/HTML5 progress bar)

陆飞龙
2023-12-01

垂直CSS / HTML5进度条(Vertical CSS/HTML5 progress bar)

我正在寻找一个垂直条,可以改变百分比类型的百分比,但以垂直格式显示,我成功地获得了一个使用此工具的水平工具: CSS Progress Bar,但现在我想仿效但垂直。

这是竖线的代码:

.score {

width:34px;

height:141px;

background: url(/assets/images/accordion/score.png) no-repeat 0 0px;

}

.score-completed {

width:26px;

margin-left: -1px;

background: url(/assets/images/accordion/score.png) no-repeat 1px 0;

}

.score-completed div {

float: right;

height: 50%;

width:26px;

margin:99px 1px 0 0;

background: url(/assets/images/accordion/score.png) no-repeat 100% 100%;

display: inline; /* IE 6 double float bug */

}

I'm looking to have a vertical bar that I can change the percent of kind of like a percent bar but in vertical format, I have succeeded in getting a horizontal one to work using this: CSS Progress Bar but now I would like to emulate that but vertically.

This is the code for the vertical bar:

.score {

width:34px;

height:141px;

background: url(/assets/images/accordion/score.png) no-repeat 0 0px;

}

.score-completed {

width:26px;

margin-left: -1px;

background: url(/assets/images/accordion/score.png) no-repeat 1px 0;

}

.score-completed div {

float: right;

height: 50%;

width:26px;

margin:99px 1px 0 0;

background: url(/assets/images/accordion/score.png) no-repeat 100% 100%;

display: inline; /* IE 6 double float bug */

}

原文:https://stackoverflow.com/questions/4245209

更新时间:2020-01-07 21:50

最满意答案

我不明白为什么你不应该自己创建 - 以下是我的尝试,并没有在IE上测试过,但它应该适用于所有现代浏览器:

#outer {

width: 30px;

height: 140px;

overflow: hidden;

position: relative;

}

#inner, #inner div {

width: 100%;

overflow: hidden;

position: absolute;

}

#inner {

bottom: 0;

height: 0%;

}

#inner div {

top: 0;

width: 100%;

height: 5px;

}

这里的基本思路是使用绝对定位的div来将条中的每个元素移动到位置 - 顶部的最里面的div用于获取圆顶,位于顶部为top: 0的进度条的top: 0 ,而进度酒吧本身底部与底部对齐bottom: 0 。

I don't see why you shouldn't build your own - the following is my attempt, and has not been tested on IE, but it should work for all modern browser:

#outer {

width: 30px;

height: 140px;

overflow: hidden;

position: relative;

}

#inner, #inner div {

width: 100%;

overflow: hidden;

position: absolute;

}

#inner {

bottom: 0;

height: 0%;

}

#inner div {

top: 0;

width: 100%;

height: 5px;

}

The basic idea here is to use absolutely positioned divs to shift each element in the bar into position - the innermost div for the top part to get the round top, positioned to the top of the progress bar with top: 0, while the progress bar itself is bottom aligned with bottom: 0.

I've set up a simple demo here: http://www.jsfiddle.net/sNLXn/. The demo uses border and background to demonstrate the progress bar, but the real thing should use images instead.

相关问答

#progressbar {

background-color: black;

border-radius: 13px; /* (height of inner div) / 2 + padding */

padding: 3px;

}

#progressbar > div {

background-color: orange;

width: 40%; /* Adjust with

...

如果我理解正确,您可以使用labelsCount选项。 例如 http://www.rgraph.net/fiddle/view.html/vprogress-with-six-labels If I understand correctly you can use the labelsCount option. eg http://www.rgraph.net/fiddle/view.html/vprogress-with-six-labels

我不明白为什么你不应该自己创建 - 以下是我的尝试,并没有在IE上测试过,但它应该适用于所有现代浏览器: #outer {

width: 30px;

height: 140px;

overflow: hidden;

position: relative;

}

#inner, #inner div {

width: 100%;

overflow: hidden;

position: absolute;

}

#inner {

bot

...

你可以旋转它: Webkit: -webkit-transform: rotate(90deg); FireFox: -moz-transform: rotate(90deg); IE: filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); You could rotate it: Webkit: -webkit-transform: rotate(90deg); FireFox: -moz-transform: rot

...

使用CSS变换旋转,然后重新定位元素,并设置宽度是高度的100%(因为你旋转)。 height:5px;

width:100vh;

transform-origin: left;

transform: translateY(-5px) rotate(90deg) ;

完整的解决方案,以HTML的修复,使正确的渲染; $(window).scroll(function () {

var s = $(window).scrollTop(),

d = $(document).h

...

您不需要伪元素来获得此效果。 这里它使用主要样式的渐变。 (仅在Chrome中测试) progress {

/* Positioning */

position: absolute;

left: 0;

top: 0;

/* Dimensions */

width: 100%;

height: 50px;

/* Reset the appearance */

-webkit-appearance: none;

-moz-app

...

你在这里的问题是你错过了设置position:relative对于li 。 li:after的连接线li:after绝对到first not position:inherit ancestor, body if none ,则在你的版本中该行应该是li元素的绝对值。 https://jsfiddle.net/bzjs1h9r/2/ 我的修复: li {

position:relative;

&.index: {

position:relative;

z-index: 3;

...

你在找这样的东西吗? CSS: div.dd {

/*position: relative; /* IE is dumb */

display: block;

float: left;

width: 500px;

height: 16px;

margin: 0 0 2px;

background: #fff;

}

div.dd div.blue {

/*position: rel

...

假设持续时间属性运行正常,我认为您不需要将“进度”乘以2。 这个 $('#progressbar').css({'width' : progress * 2});

应该 $('#progressbar').css({'width' : progress+'%' });

Assuming the duration property is functioning correctly, I think you don't need to multiply "progress" by 2. Thi

...

是。 最简单的方法是在另一个范围内放置一个跨度。 然后,几乎每个浏览器和操作系统都可以使用所有样式,并且您可以使用Javascript修改内部跨度的width属性来更改其值。

#progressContainer {

display: inline-block;

width: 400px;

hei

...

 类似资料: