Add percentage text to progress bars

Note we require extra <span> tags because the <progress> tag is an empty
tag (like <img>), and so it can't have ::before or ::after
pseudo-elements. There's a workaround for that, but currently it only
works on Chrome.

For some reason, the text seems to be slightly misaligned vertically in
all implementations I've tried. So the `top: -0.1rem` rule is a hack to
align it properly.
This commit is contained in:
Javi Martín
2019-01-11 09:19:41 +01:00
committed by decabeza
parent ce0a93be58
commit 8c5907a3fb
2 changed files with 25 additions and 5 deletions

View File

@@ -25,6 +25,21 @@
}
}
[data-text] {
display: block;
font-weight: bold;
position: relative;
&::after {
content: attr(data-text);
left: 0;
position: absolute;
text-align: right;
top: -0.1rem;
width: 100%;
}
}
progress {
$background-color: #fef0e2;
$progress-color: #fea230;