Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade Teachers Spaces Get Certified Upgrade Teachers Spaces
   ❮     
     ❯   

W3.CSSProgress Bars


A progress bar can be used to show how far along a user is in a process:

20%


Basic Progress Bar

A normal <div> element can be used for a progress bar.

The CSS width property can be used to set the height and width of a progress bar.

Example

<div class="w3-border">
  <div class="w3-grey" style="height:24px;width:20%"></div>
</div>

Try it Yourself »


Progress Bar Width

Change the width of a progress bar with the CSSwidth property (from 0 to 100%):



Example

<div class="w3-light-grey">
  <div class="w3-grey" style="height:24px;width:50%"></div>
</div>

Try it Yourself »



Progress Bar Colors

Use thew3-color classes to change the color of a progress bar:



Example

<div class="w3-light-grey">
  <div class="w3-blue" style="width:75%"></div>
</div>

Try it Yourself »


Progress Bar Labels

Add text inside aw3-container element to add a label to the progress bar.

Use thew3-center class to center the label. If omitted, it will be left aligned.

25%

50%

75%

Example

<div class="w3-light-grey">
  <div class="w3-container w3-green w3-center" style="width:25%">25%</div>
</div>

Try it Yourself »


Progress Bar Text Size

Use thew3-size classes to change the text size in the container:

50%

50%

50%

Example

<div class="w3-light-grey w3-xlarge">
  <div class="w3-container w3-green" style="width:50%">50%</div>
</div>

Try it Yourself »


Progress Bar Padding

Use thew3-padding classes to add padding to the container.

25%

25%

25%

Example

<div class="w3-light-grey">
  <div class="w3-container w3-red w3-padding w3-center" style="width:25%">25%</div>
  </div>
</div>

Try it Yourself »


Rounded Progress Bars

Use thew3-round classes to add rounded corners to a progress bar:

25%

25%

25%

Example

<div class="w3-light-grey w3-round">
  <div class="w3-container w3-round w3-blue" style="width:25%">25%</div>
</div>

Try it Yourself »


Dynamic Progress Bar

Use JavaScript to create a dynamic progress bar:


Example

<div class="w3-light-grey">
  <div id="myBar" class="w3-container w3-green"style="height:24px;width:1%"></div>
</div>

<button class="w3-button w3-light-grey" onclick="move()">Click Me</button>

<script>
function move() {
  var elem = document.getElementById("myBar");
  var width = 1;
  var id = setInterval(frame, 10);
  function frame() {
    if (width >= 100) {
      clearInterval(id);
    } else {
      width++;
      elem.style.width = width + '%';
    }
  }
}
</script>

Try it Yourself »


Dynamic Progress Bar with Labels

Centered label:

Example

20%

Try it Yourself »

Left-aligned label:

Example

20%

Try it Yourself »

Label outside of the progress bar:

Example

20%

Try it Yourself »

Another example (advanced):

Example

Added0 of 10 photos

Try it Yourself »



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2025 Movatter.jp