何らかの理由で、表内のテキストがまだ中央に配置されません。なぜでしょうか? 表内のテキストを中央に配置するにはどうすればよいですか?
本当に明確にするために、たとえば、「Lorem」を 4 つの「1」の真ん中に配置します。
@import url('http://twitter.github.com/bootstrap/assets/css/bootstrap.css');
table,
thead,
tr,
tbody,
th,
td {
text-align: center;
}
<table class="table">
<thead>
<tr>
<th>1</th>
<th>1</th>
<th>1</th>
<th>1</th>
<th>2</th>
<th>2</th>
<th>2</th>
<th>2</th>
<th>3</th>
<th>3</th>
<th>3</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="4">Lorem</td>
<td colspan="4">ipsum</td>
<td colspan="4">dolor</td>
</tr>
</tbody>
</table>
ベストアンサー1
Bootstrap 3 (3.0.3) では、要素"text-center"
にクラスを追加するtd
とすぐに機能します。
つまり、次のものはsome text
表のセルの中央に配置されます。
<td class="text-center">some text</td>