Make a
fill its parent height, without specifying height on

前端 未结 1 439
粉色の甜心
粉色の甜心 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 :

HEY
HEY
HEY
HEY
HEY
HEY
HEY

0 讨论(0)
提交回复
热议问题