How to set height of element to match height of another element?

前端 未结 2 680
孤街浪徒
孤街浪徒 2020-12-17 10:31

I currently have two columns, with another column in-between them. What I want is to have the left and right columns extend in height as the centre column has more content a

2条回答
  •  再見小時候
    2020-12-17 11:20

    Extending div to correct height, or lets say 100% height of the container, You have to chain height:100% up to the container with fixed height or to the body with another height: 100%;. On the long run, you will probably require this solution.

    Since there is no fixed height, I used height: 100% and chained up to the body an html.

    body, html { height: 100%; }
    .flight
    {
        float: right;
        border: 1px solid green;
        height: 100%;
    }
    

    Demo

    TO give exact height of container to the sidebars, you either have to use fixed height or use javascript.

提交回复
热议问题