I am looking to design div containers with a linear gradient background, each with different percentage color values.
I currently have a solution that successfully creates these div containers in a loop:
.box {
width: 500px;
height: 200px;
}
<!-- The percentage values are just variables! -->
<div style="background-image: linear-gradient(blue 0%, red 20%)" class="box">
</div>
Is it possible to create a CSS class for the gradient and set the percentage values directly through HTML code?
Pseudo Code
.box {
width: 500px;
height: 200px;
}
.gradient{
/* no colors provided! */
background-image: linear-gradient(blue, red)
}
<!-- The percentage values are just variables! -->
<div style="gradientValues: [0%, 20%]" class="box gradient">
</div>
I simply need to adjust the values of the gradient while keeping the color fixed. However, I prefer not to use JavaScript since I generate these divs from ColdFusion code. Instead, I aim to refactor the gradient color into a CSS class rather than specifying it inline as
style="background-image: linear-gradient(blue VAL1, red VAL2)"
within my HTML markup.