DIVs Arrangement - HTML CSS

后端 未结 3 1723
孤城傲影
孤城傲影 2021-01-29 08:07

\"Arrangement\"

How can i construct above arrangement without using js ?

Thanks in advance !



        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-29 08:56

    all of those techniques in the other answers have a common problem. they are assuming that the width of the first column is 150px, but actually you need min-width to be 150px. so what happens when the first column need to grow?

    take a look at my solution. pure CSS, without using calc (so its also supported in older browsers like IE8)

    Working Fiddle

    HTML: nothing new here..

    content
    content of second div is very very large

    CSS:

    #Container
    {
        width: 80%; /*Change to WTE you want*/
        display: table;
        border: 1px solid black;
        margin: 0 auto;
    }
    #Container > div
    {
        display: table-cell;
    }
    #Column1
    {
        background-color: red;
        min-width: 150px; /*From your CSS*/
    }
    
    #Column2
    {
        background-color: green;
    }
    

提交回复
热议问题