index:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>Title</title> <link rel="stylesheet" href="css.css"> </head> <body> <div style="width: 30%;margin: 10% auto"> <div style="--percent:10"></div><br/> <div style="--percent:40"></div><br/> <div style="--percent:60"></div><br/> </div> </body> </html>
css:
.progress{ position: relative; border-radius: 30px; line-height: 30px; text-align: center; background: #de0002; color: #fff; } .progress::before{ content: ""; position: absolute; left: 0; border-radius: inherit; width: calc(1%*var(--percent)); height: 100%; background: #680001; } .progress::after{ counter-reset: progress var(--percent); content: counter(progress)'%'; position: relative; }