简体   繁体   English

垂直对齐(HTML)

[英]Vertical Alignment (HTML)

Can someone please help me vertically middle align the first two columns of my table. 有人可以帮我垂直对齐表格的前两列。 Please see the code below: 请参见下面的代码:

 
<table border="1" style="width: 625px;">
<tbody>
    <tr>
        <td colspan="3" rowspan="1"><b>Property 1</b></td>
    </tr>
    <tr>
        <td colspan="1" rowspan="1">Yellow</td>
        <td colspan="1" rowspan="1">Ad</td>
        <td colspan="1" rowspan="1">abcdefgfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
        <ul>
            <li>12345</li>
            <li>4556</li>
            <li>793</li>
        </ul>
        </td>
    </tr>
</tbody>

It appear like this currently: 当前看起来像这样:

enter image description here 在此处输入图片说明

To make sure that your table is vertically aligned, add a class to your table and add this css on the head part 为了确保表格垂直对齐,请在表格中添加一个类,然后将此CSS添加到头部

.verticalTable tr td {
  vertical-align:middle;
}

Here's a link 这是一个链接

try adding this css: 尝试添加此CSS:

table tr td:nth-child(1),td:nth-child(2){
    text-align: center;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM