Fill remaining vertical space - only CSS

前端 未结 9 1409
日久生厌
日久生厌 2020-11-28 09:15

I need to fill the remaining vertical space of #wrapper under #first with #second div.

I need an only CSS sol

9条回答
  •  抹茶落季
    2020-11-28 09:49

    You can do this with position:absolute; on the #second div like this :

    FIDDLE

    CSS :

    #wrapper{
        position:relative;
    }
    
    #second {
        position:absolute;
        top:200px;
        bottom:0;
        left:0;
        width:300px;
        background-color:#9ACD32;
    }
    

    EDIT : Alternative solution

    Depending on your layout and the content you have in those divs, you could make it much more simple and with less markup like this :

    FIDDLE

    HTML :

    CSS :

    #wrapper {
        height:100%;
        width:300px;
        background-color:#9ACD32;
    }
    #first {
        background-color:#F5DEB3;
        height: 200px;
    }
    

提交回复
热议问题