0

I want to make last two columns "Current cash and grand total" having only one line in center and text aligned in center but row span iis not working here is the pic enter image description here

and here is html css code

{% extends "layout.html" %}

{% block title %}
Your Portfolio
{% endblock %}

{% block main %}
<style type="text/css">
  table{


width: 100%;
height: 50px;
  }

  table td,th{
    border: 1px solid black;
    text-align: center;
  }
  table th{
       background-color: #4CAF50;
  }

</style>
<table>
    <tr>
        <th>Stocks</th>
        <th>Shares</th>
    <th>Current Price</th>
    <th>Total</th>
    <th>Current Cash</th>
    <th>Grand Total</th>

</tr>

{% for stock in symbol %}
    <tr>
        <td>{{ stock["symbol"] }}</td>
        <td>{{ stock["shares"] }}</td>
        <td>{{ stock["quoteprice"] }}</td>
        <td>{{stock["shares"] * stock ["quoteprice"]}} </td>

{% endfor %}
    <td rowspan = "3">{{cash}}</td>
    <td rowspan = "3">{{gtotal}}</td>
    </tr>

{% endblock %}

1

You have more <tr> than </tr>, and the rowspan elements probably should be in the first row.

Maybe you can try something like

{% for stock in symbol %}
    <tr>
        <td>{{ stock["symbol"] }}</td>
        <td>{{ stock["shares"] }}</td>
        <td>{{ stock["quoteprice"] }}</td>
        <td>{{stock["shares"] * stock ["quoteprice"]}} </td>
        {% if loop.first %}
            <td rowspan = "{{loop.length}}">{{cash}}</td>
            <td rowspan = "{{loop.length}}">{{gtotal}}</td>
        {% endif %}
    </tr>
{% endfor %}
1
  • Thanks a lot this worked... – Ahmed Raza Mar 14 '17 at 10:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .