0

I'm trying to make a progress bar with the CSS attr function, here is my code :

.progress_bar { height: 10px; width: 10cm; background-color: #cae3ff; } .progress { height: inherit; width: attr(progress); background-color: #0077ff; transition: 1s cubic-bezier(1,0,0,1); }
<div class="progress_bar"> <div class="progress" progress="80%"></div> </div>

As you can see by running the code snippet, the bar doesn't work, I read the docs about the attr function and still I don't find the problem, could you help me please ?

4 Answers 4

2

attr() was originally intended for use with the content property and support for it there is good.

CSS Values and Units Module Level 4 adds support for any property (such as width), but that specification is currently a Working Draft and browser support is non-existent.

Sign up to request clarification or add additional context in comments.

Comments

2

Try using the width rule in the style attribute like style="width:50%"

Comments

0

I found another way :

.progress_bar { height: 10px; width: 10cm; background-color: #cae3ff; } .progress { height: inherit; background-color: #0077ff; transition: 1s cubic-bezier(1,0,0,1); }
<div class="progress_bar"> <div class="progress" style="width:80%"></div> </div>

Using the style attribute, instead of creating a new attribute.

Comments

0

Try this one.

.progress_bar { height: 10px; width: 10cm; background-color: #cae3ff; } .progress { height: inherit; width: calc(var(--width, 0) * 1%); background-color: #0077ff; transition: 1s cubic-bezier(1,0,0,1); }
<div class="progress_bar"> <div class="progress" style="--width: 80;"></div> </div>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.