I am trying to apply custom values to specific styles. In my static style sheet, which works if I list the items separately but not if I try to populate the style with a for loop.
I have created a set of specific styles:
.item_1, .item_2, .item_3, .item_4, .item_5, .item_6, .item_7, .item_8 {
width: 8vw;
height: 14vh;
padding: 10px;
align-content: center;
background-color: white;
border: 2px solid black;
display: inline-block;
vertical-align: middle;
text-align: center;
font-size: 2vh;
border-radius: 15px;
box-sizing: border-box;
}
each one corresponds to a specific item in a flex box to render:
in order to be able to change the background color as required.
changing colors via hardcoding works fine using a list of colors via context, i.e:
div.item_1 {
background-color: {{ color.0 }};}```
however, if I use zip to create a set from two lists, div.item_1 ... and color, it renders a blank style:
{
background-color: ;}
The result of:
divcontext_colors_zip = list(zip(divcontext,area_colors))```
is:
[('div.item_1', 'Red'), ('div.item_2', 'Yellow'), ('div.item_3', 'Yellow'), ('div.item_4', 'Green'), ('div.item_5', 'Yellow'), ('div.item_6', 'Yellow'), ('div.item_7', 'Green')]
and is passed as divcontext_colors_zip:
"divcontext_colors_zip": divcontext_colors_zip,
the loop I use is:
<style>
{% for x_topics in divcontext_colors_zip %}
{{ x_topics.divcontext}} {
background-color: {{ x_topics.area_colors }};}
{% endfor %}