Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I put text into a progress bar in HTML5 with bulma?

Tags:

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.

like image 402
Oskar Sherrah Avatar asked Nov 13 '18 10:11

Oskar Sherrah


People also ask

Which is the correct implementation for a progress bar in html5?

Use the <progress> tag to create a progress bar in HTML. The HTML <progress> tag specifies a completion progress of a task. It is displayed as a progress bar.

How can get progress bar value in HTML?

The progress object in HTML DOM is used to represent the HTML <progress> element. The <progress> element can be accessed by using getElementById() method. Property Values: level: It returns the list of progress bar.

What is progress bar in bootstrap?

A progress bar can be used to show a user how far along he/she is in a process. Bootstrap provides several types of progress bars. A default progress bar in Bootstrap looks like this: 70% Complete.


1 Answers

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>
like image 122
Temani Afif Avatar answered Oct 15 '22 23:10

Temani Afif