77
rated 0 times
[
81]
[
4]
/ answers: 1 / hits: 5272
/ 3 Years ago, wed, april 14, 2021, 12:00:00
I have these different div elements with classes such as red
or green
.
<div class="sidebar">
<div class="color_box red"></div>
<div class="color_box orange"></div>
<div class="color_box yellow"></div>
<div class="color_box green"></div>
<div class="color_box blue"></div>
<div class="color_box purple"></div>
<div class="color_box black"></div>
<div class="color_box white"></div>
</div>
I want to set the background color of the div element to its class name. So if the class name is red
, I would want the div background to be red. I'm not sure if I need to add javascript or something else. I've looked at this and it was not what I wanted at all.
Thank you in advance!
More From » html