简体   繁体   English

样式化 django 模板引导程序中的代码片段

[英]code snippets in styling django template bootstrap

I have to include variables while styling django templates using Bootstrap.我必须在使用 Bootstrap 设置 django 模板样式时包含变量。

<div class="card mb-2 text-white bg-info">

The info part will be changed for each card accordingly.每张卡的信息部分将相应更改。 Is there any way similair to this ?有没有类似的方法?

<div class="card mb-2 text-white bg-{card.category}">

card is from the respective model. card来自相应的型号。

Please help请帮忙

Putting a condition can be helpful:设置条件可能会有所帮助:

<div class="card mb-2 text-white bg-
    {% if card.category==value1 %} class A 
    {% elif card.category==value2 %} class B
    {% else %} class C
    {% endif %}
">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM