2017-03-08 121 views
3

我有一個引導懸停表,我試圖通過使用<th align="center">將列標題對齊到中間。這似乎對桌子沒有任何影響,但<td align="center">正常工作。<th 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> 
+0

對準應該由CSS,而不是HTML處理。 –

回答

17

如果你使用的引導,使用它的CSS規則。

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

是的,這樣做,但我也應該使用這個爲​​,因爲它似乎沒有類 – DeA

+0

正如我所說,對齊(和所有其他演示文稿)不應該用HTML來完成,它應該用CSS 。 'align'已被棄用。 –

4

使用此

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

屬性一致,因爲自舉樣式表無法正常工作找到這個:

th { 
    text-align:left 
} 
相關問題