5

By default, what you put in between the <progress></progress> tags will not show.

<progress class="progress" value="15" max="100">15%</progress>

How would I get the 15% to show? I am using Bulma as a framework.

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Oskar Sherrah
  • 93
  • 1
  • 10
  • Possible duplicate of [Bulma progress text in middle](https://stackoverflow.com/questions/50400219/bulma-progress-text-in-middle) –  Nov 18 '18 at 14:11

2 Answers2

4

Use pseudo element and data attribute (works only on chrome ...)

.progress:before {
  content:attr(data-text);
}
.progress {
 text-align:center;
}
<progress class="progress" value="15" max="100" data-text="15%"></progress>

Or you can simply consider an extra wrapper:

.progress:before {
  content:attr(data-text);
  position:absolute;
  left:0;
  right:0;
}
.progress {
 text-align:center;
 display:inline-block;
 position:relative;
}
<div class="progress" data-text="15%"><progress  value="15" max="100" ></progress></div>

Including bulma:

.progress-container:before {
  content: attr(data-text);
  position: absolute;
  left: 0;
  right: 0;
  top:0;
  line-height:1em;
}

.progress-container {
  text-align: center;
  position: relative;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" rel="stylesheet" />
<div class="progress-container" data-text="15%"><progress class="progress" value="15" max="100"></progress></div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
0

Wrap you progress with div and add span

(I did not use :after/before and it has to work in all browser)

See fiddle using bulma

<div>
<span>
  15%
</span>
<progress  class="progress" value="15" max="100" >

</progress>
</div>

CSS:

span{
    position: absolute;
    top: -2px;
    left: 50%;
    font-size: 12px;
}
לבני מלכה
  • 15,925
  • 2
  • 23
  • 47