如何使表格居中

时间:2016-03-04 16:44:46

标签: html5 twitter-bootstrap css3 html-table

这就是我下面的内容,我只需要使表格居中。如何使表格居中?对于我正在使用bootstrap CSS3和HTML5的网站

这是整个部分 - 其余部分都很好并且工作正常,我只是遇到了问题。我不能把它集中在一起:

<section id="international" class="international">

<div class="section-heading">
<h6 class="title wow fadeInDown" data-wow-delay=".3s"> Available     Internationally</h6>



<p class="wow fadeInDown" data-wow-delay=".5s">
<div class="para">

        test text

<br>


<style type="text/css">

.tg  {border-collapse:collapse;border-spacing:0;border:none;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:1px 10px;border-style:solid;border-width:0px;overflow:hidden;word-break:normal;}
.tg th{font-family:roboto, sans-serif;font-size:16px;font-weight:normal;padding:1px 10px;border-style:solid;border-width:0px;overflow:hidden;word-break:normal;}
.tg .tg-yfiy{font-weight:bold;font-size:16px;vertical-align:bottom}
.tg .tg-qv16{font-weight:bold;font-size:16px;text-align:center;vertical-align:top}
.tg .tg-k010{font-weight:bold;font-size:16px;text-align:center;vertical-align:bottom}
.tg .tg-yw4l{vertical-align:top}
.tg .tg-qnmb{font-weight:bold;font-size:16px;text-align:center}

</style>

<table align="center" class="tg" style="undefined;table-layout: fixed; width: 563px">

<colgroup>
<col style="width: 166px">
<col style="width: 81px">
<col style="width: 79px">
<col style="width: 86px">
<col style="width: 85px">
<col style="width: 66px">
</colgroup>
<tr>
<th class="tg-yfiy">test</th>
<th class="tg-k010">one</th>
<th class="tg-qv16">two</th>
<th class="tg-qv16">three</th>
<th class="tg-qv16">four</th>
<th class="tg-qv16">five</th>
</tr>
<tr>
<td class="tg-yw4l"></td>
<td class="tg-qnmb">one</td>
<td class="tg-qv16">two</td>
<td class="tg-qv16">three</td>
<td class="tg-qv16">four</td>
<td class="tg-qv16">five</td>
</tr>
</table>  


</div>
</div>
</section>  

1 个答案:

答案 0 :(得分:1)

我在我身上试过这个,似乎是centered。您可以尝试:margin-left:auto; margin-right:auto进行水平对齐; margin-top:auto; margin-bottom:auto,用于垂直对齐或 两者都是margin:auto