two divs side by side, one 100% width others width depended on content

后端 未结 1 678
故里飘歌
故里飘歌 2020-12-04 18:31

I want to place two DIV tags side by side without using fixed width. The first div expands to its content and the second div should fill the remaining space. Also the div

相关标签:
1条回答
  • 2020-12-04 19:05

    See: http://jsfiddle.net/kGpdM/

    #left {
        background: #aaa;
        float: left
    }
    #right {
        background: cyan;
        overflow: hidden
    }
    

    This works in all modern browsers and IE7+.

    The left column will be exactly as wide as the content inside it. The right column will take the remaining space.

    The overflow: hidden "trick" behind this answer is explained here.

    0 讨论(0)
提交回复
热议问题