Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML CSS: fix and stretch width two column layout

Tags:

html

css

layout

<div style="width: 800px; height: 600px">

    <div style="float:left; width: 100px">
        left fixed-width column
    </div>
    <div style="???">
        right stretching column (the width should be 700px in this case.)
    </div>

</div>

What's the standard way to create two column layout where the left one is fixed-size and the right one stretches?

  • I would like both columns' styles are independent. I found a couple of solutions here, but if I change the width of the left column, the right column's style (e.g. margin) need to be changed along with it.

  • I don't need to support old browsers. If it's standard, it's just okay.

like image 407
user1392013 Avatar asked Nov 05 '22 00:11

user1392013


1 Answers

Apply overflow: hidden to the second div. This will introduce a new block formatting context. You can find some more information in Can overflow:hidden affect layout?.

jsFiddle Demo

like image 99
kapa Avatar answered Nov 07 '22 21:11

kapa