【问题标题】:how to get elements in separated rows in html table?如何获取html表中分隔行中的元素?
【发布时间】:2020-05-10 02:50:45
【问题描述】:

嘿,我正在从 excel 文件中获取数据,但所有数据都只返回一个行框中,这是我的 html 代码


{% block body %}

# i am using bootstrap table class
    <table class="table table-bordered">
        <thead>
            <tr>
              <th scope="col">Pensioner name</th>
              <th scope="col">cnic</th>
              <th scope="col">mobile</th>
              <th scope="col">wallet</th>


            </tr>
          </thead>

            <tr>
                {% if 'm1' %}
                <td><h6 >{{ m1 }}</h6></td>
                {% endif %}

                {% if 'm2' %}
                <td><h6 >{{ m2 }}</h6></td>
                {% endif %}
                {% if 'm3' %}
                <td><h6 >{{ m3 }}</h6></td>
                {% endif %}
                {% if 'm4' %}
                <td><h6 >{{ m4 }}</h6></td>
                {% endif %}
          </tr>
    </table>
{% endblock %}

这是我的输出enter image description here

我想把数据放到单独的行框中,现在看起来很乱,请帮忙

【问题讨论】:

    标签: html css html-table bootstrap-4


    【解决方案1】:

    要创建新行,您需要为每一行添加一个新的 &lt;tr&gt; 元素。

    这是一个工作示例

    table,
    tr,
    th,
    td {
      border: solid 1px;
    }
    <table>
      <thead>
        <tr>
          <th>First Name</th>
          <th>Last Name</th>
          <th>Job Title</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>James</td>
          <td>Matman</td>
          <td>Chief Sandwich Eater</td>
        </tr>
        <tr>
          <td>The</td>
          <td>Tick</td>
          <td>Crimefighter Sorta</td>
        </tr>
      </tbody>
    </table>

    &lt;tbody&gt; 元素内的每个 &lt;tr&gt; 元素都会创建一个新行。

    【讨论】:

    • 对不起,但这仍然不起作用,请考虑这些'm'变量包含多行而不是单行
    • 哦,我明白了。我虽然因为问题的标签而询问如何构建 HTML。我建议您添加与您的问题所涉及的技术相关的所有标签。
    猜你喜欢
    • 1970-01-01
    • 2018-11-12
    • 1970-01-01
    • 2013-03-02
    • 1970-01-01
    • 2020-06-09
    • 1970-01-01
    • 2016-12-06
    • 1970-01-01
    相关资源
    最近更新 更多