【发布时间】:2020-09-18 15:47:13
【问题描述】:
我正在尝试创建此进度条,但由于它具有边框半径和每个子进度元素的不同边框颜色而很困难。
这是我目前取得的成果,不包括边框: Codepen
body {
display: flex;
justify-content: center;
}
.progress-bar {
height: 24px;
width: 280px;
background: #eaeaea;
border-radius: 16px;
display: flex;
overflow: hidden;
}
.progress-bar-fill-1 {
width: 30%;
background: #F16172;
box-sizing: border-box;
border-right: 1px solid white;
}
.progress-bar-fill-2 {
width: 20%;
background: #31C4F3;
box-sizing: border-box;
border-right: 1px solid white;
}
<div class="progress-bar">
<div class="progress-bar-fill-1"></div>
<div class="progress-bar-fill-2"></div>
</div>
例如,如果我尝试为.progress-bar-fill-1 添加边框,它不会出现在角落上。
注意,我事先不知道百分比值,所以无法通过在第一个进度元素中添加border-radius 来解决问题。
谢谢
【问题讨论】:
-
你能分享你的html代码吗?我没有道理。
-
@MaximJin 我添加了我卡在其中的代码...不知道如何为每个元素添加边框。
-
您添加了隐藏在父元素中的溢出。如果只在第一个元素中添加边框, .progress-bar-fill-1 {border-radius: 16px; }
-
是的,我在问题中提到它只会对这个例子有所帮助,但它不够通用......我需要为每个案例找到一个 css 解决方案。