Html <th align'"center"> 不适用于引导表。可能是什么原因?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42682942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:29:15  来源:igfitidea点击:

<th align'"center"> not working on a bootstrap table. What might be the reason?

htmltwitter-bootstrap

提问by DeA

I have a bootstrap hover table and I'm trying to align the column headers to the middle by using <th align="center">. This seems to have no effect on the table whatsoever, but <td align="center">works properly.

我有一个引导悬停表,我正在尝试使用<th align="center">. 这似乎对桌子没有任何影响,但<td align="center">工作正常。

This is my code:

这是我的代码:

<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>

回答by Eduardo Escobar

If you're using bootstrap, use its CSS rules.

如果您使用引导程序,请使用其 CSS 规则。

<th class="text-center">Product</th>

回答by Davide

Use this

用这个

<th class="text-center">Product</th>

attribute align not work because on bootstrap stylesheet find this:

属性 align 不起作用,因为在引导样式表上找到这个:

th {
    text-align:left
}