开发者

Change HTML with variables in Django

I have the dict latest_status:

{'What': 10, "Study'": 10, 'all': 10, 'to': 10, "facebook'": 10, 'has': 10, 'worth': 20, 'hurting': 10 }

I am trying to make a text 开发者_运维问答cloud by doing something like this in my template:

{% for word,count in latest_status.items %}
<style="font-size:{{ count }}px"> {{ word }}</style> 
{% endfor %}

I am trying to manipulate the font size with the count from the dict but it doesn't seem to be working.


The <style> tag is used to introduce a block (or external resource) containing style definitions. You'll want to encapsulate your text in a presentation tag of some sort--for example:

{% for word,count in latest_status.items %}
<p style="font-size:{{ count }}px;"> {{ word }}</p>
{% endfor %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜