如何将 HTML 表格的内容居中? [英] How to center the contents of an HTML table?
问题描述
我正在使用 HTML I am using an HTML 如何将文本水平和垂直居中对齐? How do I center align the text horizontally and vertically? 这是一个带有 CSS 和内联 Here is an example with CSS and inline EDIT: EDIT: The 这篇关于如何将 HTML 表格的内容居中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 并且我想将
的文本与每个单元格的中心对齐.
<table>
and I want to align the text of <td>
to the center in each cell.推荐答案
style
属性的示例:style
attributes:td
{
height: 50px;
width: 50px;
}
#cssTable td
{
text-align: center;
vertical-align: middle;
}
<table border="1">
<tr>
<td style="text-align: center; vertical-align: middle;">Text</td>
<td style="text-align: center; vertical-align: middle;">Text</td>
</tr>
</table>
<table border="1" id="cssTable">
<tr>
<td>Text</td>
<td>Text</td>
</tr>
</table>
valign
属性在 HTML5 中已弃用,不应使用.valign
attribute is deprecated in HTML5 and should not be used.
登录
关闭