【问题标题】:how to iterate over multiple html paragraphs in jinja如何在 jinja 中遍历多个 html 段落
【发布时间】:2020-03-15 13:06:22
【问题描述】:

我想遍历一个包含

的数据库
  1. 标题
  2. 一段

如何将内容分成 2 列?

希望制作此代码:

{% for stor in story %}
 <h1>{{stor.title}}</h1>
  <p class = "story">{{stor.body}}</p> 
  {% endfor %}

看起来像这样:

<div class="container">
  <div class="row">
    <div class="col-md">
      <h1>header text</h1>
      <p>paragraph text</p>
    </div>
    <div class="col-md">
      <h1>header text</h1>
      <p>paragraph text</p>
    </div>
  </div>
</div>

在显示数据库中的文本时

【问题讨论】:

  • 你试过&lt;table&gt;吗?
  • 你试过了吗?

标签: python html css flask jinja2


【解决方案1】:

使用HTML Tables 在列中显示数据。你可以这样做:

 <table>
  <tr>
    <th>Title</th>
    <th>Story</th>
  </tr>
  {% for stor in story %}
    <tr>
      <td>{{stor.title}}</td>
      <td>{{stor.body}}</td>
    </tr>
  {% endfor %}
</table> 

有关HTML Tables 的更多详细信息:https://www.w3schools.com/html/html_tables.asp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-15
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多