简体   繁体   中英

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

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

Here's a link

try adding this css:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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