I have the following situation:
I'm displaying multiple div boxes, each with differing width depending on the context.
For example:
.demand-2 {
width: 29%;
}
.demand-3 {
width: 43%;
}
A div with demand-2 is supposed to only be 29% of its parent width.
Now, there's a button that increases all the boxes to a width of 100%. With the following CSS I make sure that the transition is smooth:
maxLevelOff {
animation-duration: 1s;
animation-name: maxOff;
animation-fill-mode: forwards;
}
@keyframes maxOff {
from {
width: 29;
}
to {
width: 100%;
}
}
This works perfectly fine, however, as you can see, only for demand-2 since I had to hard code it.
My question now, is there a way I can do this dynamically? Otherwise I'd have to create an animation for all the different widths and that seems tedious.
This should also go the other way. In other words, if I click the button again, all the boxes should transit from 100% back to their original size.