我有一个 bootstrap 悬停表,我正在尝试使用 <th align="center">
将列标题对齐到中间.这似乎对表格没有任何影响,但是 <td align="center">
正常工作。
这是我的代码:
<table class="table table-hover">
<thead>
<tr>
<th>Title</th>
<th>Score</th>
<th align="center">Product</th> #This line is not working
<th>Who Reviewed</th>
<th>When</th>
</tr>
</thead>
<tbody>
{% for review in object_list %}
<tr>
<td><a href="{% url 'backend_reviews_edit' review.pk %}">{{review.title}}</a></td>
<td align="center">{{ review.score }}</td>
<td align="center">{{ review.product.title }}</td>
<td>{{ review.reviewer_name}}</td>
<td>{{ review.date_created|date:"m-d-Y" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
最佳答案
如果您使用的是 Bootstrap ,请使用它的 CSS 规则。
<th class="text-center">Product</th>
关于html - <th align '"center"> 不在 Bootstrap 表上工作。可能是什么原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42682942/