如何更改 HTML 中进度条值的颜色?

问题描述 投票:0回答:5

progress {
  border: none;
  width: 400px;
  height: 60px;
  background: crimson;
}

progress {
  color: lightblue;
}

progress::-webkit-progress-value {
  background: lightblue;
}

progress::-moz-progress-bar {
  background: lightcolor;
}
<div>
  <progress min="0" max="100" value="63" />
</div>

我几乎尝试了所有方法,但进度条的值颜色保持不变。唯一能够响应变化的浏览器是 IE。 Firefox 只允许更改背景颜色。 Chrome 根本不显示任何内容。你能发现我的代码有什么问题吗?

css html progress-bar
5个回答
30
投票

progress {
  border: none;
  width: 400px;
  height: 60px;
  background: crimson;
}

progress {
  color: lightblue;
}

progress::-moz-progress-bar {
  background: lightblue;
}

progress::-webkit-progress-value {
  background: red;
}

progress::-webkit-progress-bar {
  background: blue;
}
It will work on webkit browser, like this example

<div>
  <progress min="0" max="100" value="63" />
</div>


5
投票

您可以简单地使用

accent-color
变量而不是
color
background
,而不是制作自己的进度条。

progress {
  width: 400px;
  height: 60px;
}

.colored {
  accent-color: red;
}
<div>
  <p>Default: <progress min="0" max="100" value="63" /></p>
  <p>Colored: <progress class="colored" min="0" max="100" value="63" /></p>
</div>


0
投票
progress {
  width: 400px;
  height: 60px;
}

.colored {
  accent-color: red;
}

-1
投票

你能做的事情非常有限,但这一定能解决问题

progress {
   -webkit-appearance: none;
}
progress::-webkit-progress-bar-value {
  -webkit-appearance: none;
  background: orangered;
}

-3
投票

用这个

强调色:“#fff

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.