height: 100% for
inside
with display: table-cell

后端 未结 7 1466
醉话见心
醉话见心 2020-11-29 21:44

Here is 2 column markup using display: table and display: table-cell CSS declarations:

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 22:25

    When you use % for setting heights or widths, always set the widths/heights of parent elements as well:

    .table {
        display: table;
        height: 100%;
    }
    
    .cell {
        border: 2px solid black;
        vertical-align: top;
        display: table-cell;
        height: 100%;
    }
    
    .container {
        height: 100%;
        border: 2px solid green;
        -moz-box-sizing: border-box;
    }

    Text

    Text

    Text

    Text

    Text

    Text

    Text

    Text

    Text

提交回复
热议问题