Make a
fill its parent height, without specifying height on

前端 未结 1 415
粉色の甜心
粉色の甜心 2021-01-13 13:46

I know there is a similar question here, but it doesn\'t work in my case.


            <         
相关标签:
1条回答
  • 2021-01-13 14:20

    I found a solution by adding an inner div into each div.Key and using display: table; and display: table-cell; This does what I need. Here is the code:

    .Layout {
        width: 1024px; /* TEST */
        height: 480px; /* TEST */
    }
    .Key {
        text-align: center;
        display: table;
        width: 100%;
        height: 100%;
    }
    .Key > div {
        display: table-cell;
        vertical-align: middle;
    }
    

    And :

    <table class="Layout">
        <tbody>
            <tr>
                <td><div class="Key"><div>HEY</div></div></td>
                <td><div class="Key"><div>HEY</div></div></td>
                <td><div class="Key"><div>HEY</div></div></td>
                <td><div class="Key"><div>HEY</div></div></td>
                <td><div class="Key"><div>HEY</div></div></td>
                <td><div class="Key"><div>HEY</div></div></td>
                <td><div class="Key"><div>HEY</div></div></td>
            </tr>
        </tbody>
    </table>
    
    0 讨论(0)
提交回复
热议问题