How to force child div to be 100% of parent div's height without specifying parent's height?

前端 未结 26 2009
刺人心
刺人心 2020-11-22 06:52

I have a site with the following structure:

<
26条回答
  •  轮回少年
    2020-11-22 07:35

    I had the same issue, it worked based on Hakam Fostok's answer, I've created a small example, in some cases it might work without having to add display: flex; and flex-direction: column; on the parent container

    .row {
        margin-top: 20px;
    }
    
    .col {
        box-sizing: border-box;
        border: solid 1px #6c757d;
        padding: 10px;
    }
    
    .card {
        background-color: #a0a0a0;
        height: 100%;
    }
    

    JSFiddle

提交回复
热议问题