Make Div on right side fill out all available space

后端 未结 5 1346
清酒与你
清酒与你 2021-01-28 04:27

I want to create two divs beside each other, however I want the one on the left side to be 300px, and the right one to take up the remaining amount on the screen. How would that

5条回答
  •  孤城傲影
    2021-01-28 05:13

    This should be sufficient:

    • overflow: hidden will stretch the container div to accommodate the tallest child element
    • float: left floats the element left (doh!)
    • width: 300px and margin-left: 300px together assures that if the right column is taller than left it will not flow below the left floated div; it will maintain a 300x gap from the left edge of container div

    Tip: change to margin-left: 320px to add a 20px gutter

    Here is a nice little DEMO

提交回复
热议问题