I'm currently working on the cs50 Final Project (a website). So I'm printing the data in a sqlite table as an html table for a page of my website. However, my table headers and data sometimes took up multiple lines each. To correct this, I made sure white-space didn't wrap. Although that fixed that problem, it introduced another - my table is all the way to the right! I tried multiple methods to center the table, but none worked. Any help in centering the table is appreciated.
Here's the html for the table:
{% extends "layout.html" %}
{% block title %}
All Sets
{% endblock %}
{% block main %}
<link href="{{ url_for('static', filename='legoset.css') }}" rel="stylesheet"/>
<table class="table table-striped">
<thead>
<th>Set Number</th>
<th>Set Variant</th>
<th>Set Theme</th>
<th>Set Subtheme</th>
<th>Year Released</th>
<th>Set Name</th>
<th>Minifig Count</th>
<th>Number of Pieces</th>
<th>Set Price (USD)</th>
<th>Set Image (url)</th>
</thead>
{% for row in rows %}
<tr>
<td>{{ row.Number }}</td>
<td>{{ row.Variant }}</td>
<td>{{ row.Theme }}</td>
<td>{{ row.Subtheme }}</td>
<td>{{ row.Year }}</td>
<td>{{ row.Name }}</td>
<td>{{ row.Minifigs }}</td>
<td>{{ row.Pieces }}</td>
<td>{{ row.USPrice }}</td>
<td>{{ row.ImageURL }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
And here's the linked css:
table {
margin: 0px auto;
float: none;
}
th, td {
text-align: center;
white-space: nowrap;
}