Make div fill remaining space of parent

前端 未结 4 2210
不知归路
不知归路 2021-02-13 13:01

I need some help with positioning divs. The HTML structure is as follows:

4条回答
  •  不知归路
    2021-02-13 13:32

    Something like this might work:

    http://jsfiddle.net/PCvy9/2/

    The main key of what you're looking for lines in the:

     .right {
       overflow: hidden;
       background-color: #C82927;
     }
    

    This is due to something called the "block formatting context." Great reasoning and tutorial as to why here: http://colinaarts.com/articles/the-magic-of-overflow-hidden/#making-room-for-floats

    However, their heights are not completely linked; in this example, your left side block's height would still need to be manually set (as it's a floated container)

提交回复
热议问题