-1

I'm really new to HTML, and I work with Python on this.

I have a few seperated HTML "objects" and I want to show, one after one, and I need a space between them.

This is an example I saw on the net:

enter image description here

Here we can see 3 different HTML "objects" and we can see the space between them.

How do I show them on one page?

My Code:

def nlist_to_html(kpi_data_dict):

    headers_lists = ['Total Revenue'] 
    htable = '<br> <table bordercolor=000000 cellspacing="0" cellpadding="1" ' \
             'style="table-layout:fixed; background: #F5F5F5; vertical-align:bottom; font-size:15px;font-family:verdana,sans,sans-serif;border-collapse:collapse;border:3px solid rgb(12, 73, 173); color:rgb(20, 99, 226)" >'

    for header in headers_lists:
        new_header = '<header> <h1> <th bgcolor = "#777" colspan = "6" align = "left" valign = "center"> <font size = "6" color ="white"> {header} </font> </th> </h1> </header>'.format(header= header)
        htable += new_header

        for row in kpi_data_dict:
            newrow = u'<tr>'
            newrow += u'<td align="left" style="padding:1px 4px">' + unicode(row[1][1]) + u'</td>'
            newrow = newrow + ''.join([u'<td align="center" style="padding:1px 4px">' + unicode(x) + u'</td>' for x in row])
            newrow += '</tr>'
            htable += newrow
        htable += '</table>'

    return htable
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
shayms8
  • 671
  • 6
  • 13
  • 28

1 Answers1

0

I am not sure, what language do you use in this back-end script, but try this:

def nlist_to_html(kpi_data_dict):
headers_lists = ['Total Revenue'] 
htable = '<br> <table bordercolor=000000 cellspacing="0" cellpadding="1" ' \
         'style="table-layout:fixed; background: #F5F5F5; vertical-align:bottom; font-size:15px;font-family:verdana,sans,sans-serif;border-collapse:collapse;border:3px solid rgb(12, 73, 173); color:rgb(20, 99, 226)" >'

for header in headers_lists:
    new_header = '<tr> <th bgcolor = "#777" colspan = "6" align = "left" valign = "center" style="margin-top:15px;"> <header> <h1> <font size = "6" color ="white"> {header} </font> </h1> </header> </th> </tr>'.format(header= header)
    htable += new_header

    for row in kpi_data_dict:
        newrow = u'<tr>'
        newrow += u'<td  align="left" style="padding:1px 4px; margin-top:15px;">' + unicode(row[1][1]) + u'</td>'
        newrow = newrow + ''.join([u'<td align="center" style="padding:1px 4px; margin-top:15px;">' + unicode(x) + u'</td>' for x in row])
        newrow += '</tr>'
        htable += newrow
    htable += '</table>'

return htable
Yuri Gor
  • 1,353
  • 12
  • 26