【发布时间】:2022-02-23 15:01:35
【问题描述】:
Ionic 进度条的actual version 没有显示百分比文本的选项。
我尝试使用::after 选择器手动添加它,但无济于事。
这是我的 Ionic 代码:
ion-progress-bar {
height: 18px;
border-radius: 20px;
}
<ion-progress-bar color="success" value="0.9"></ion-progress-bar>
在检查元素时,这是我在 chrome 的元素检查器中得到的
.progress, .progress-indeterminate {
background: var(--progress-background);
z-index: 2;
}
.buffer-circles, .indeterminate-bar-primary, .indeterminate-bar-secondary, .progress, .progress-buffer-bar, .progress-buffer-bar:before, .progress-indeterminate {
left: 0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
width: 100%;
height: 100%;
}
<ion-progress-bar _ngcontent-c0="" color="success" value="0.9" ng-reflect-value="0.9" ng-reflect-color="success" role="progressbar" aria-valuenow="0.9" aria-valuemin="0" aria-valuemax="1" class="ion-color ion-color-success progress-bar-determinate hydrated">
#shadow-root
<!-- ....... -->
<div class="progress" style="transform: scaleX(0.9);"></div>
<div class="progress-buffer-bar" style="transform: scaleX(1);"></div>
</ion-progress-bar>
我可以将元素检查器中的文本添加到进度条的唯一方法是将其添加到带有 progress 类的 div 中:
<div class="progress" style="transform: scaleX(0.9);">90%</div>
但无法从我的 Ionic 代码中添加此文本,因此我尝试使用 ::after 选择器,但它不起作用:
.progress:after{
content: "90%";
}
我不需要文本动态变化,因为进度条必须显示一个不变的静态值。
谢谢!
【问题讨论】:
标签: css progress-bar ionic4