我对Django很陌生,我一直在想这个问题
是否有任何方法可以将模板语法放入CSS选择器中,如下所示:
{% for i in list %}
<!-- I know for a fact that 'list' has data in it -->
<div id='div{{ forloop.counter }}'>test{{ forloop.counter }}</div>
<style>
#div{{ forloop.counter }} {
color: blue;
}
</style>
{% endfor %}
并让它生成以下代码:
<div id='div1'>test1</div>
<style>
#div1 {
color: blue;
}
</style>
<div id='div2'>test2</div>
<style>
#div2 {
color: blue;
}
</style>
<div id='div3'>test3</div>
<style>
#div3 {
color: blue;
}
</style>
我尝试过这个,但是<style>
标记完全不起作用
有没有办法做到这一点,如果有,如何做到
据我所知,在css中使用模板语法是不可能的
相关问题 更多 >
编程相关推荐