Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make two divs side by side, one is resizable and the other has same height

Tags:

html

css

I bring here a drama with css height.

I would like to make a layout, a div that contains 2 divs both in same line, one is resizable and the other must fit in the parent's height (same height as the first one).

The first div can have additional information (so i can't fix the height), so it will have more lines, the important is that it must not have a scroll bar. The second div must obey the first height, if it's bigger than it will have a scroll bar.

<div class='container'> <!-- parent -->
    <div class='left'> <!-- resizable -->
    </div>
    <div class='right'> <!-- same height as left div  -->
    </div>
</div>

UNSOLVED CODE

The problem is that i can't figure out how to make it just using css. Or even it's possible just with css. I would not like to use js.

Someone please help me!

like image 770
korogui Avatar asked Jul 24 '13 07:07

korogui


People also ask

How do I keep two side by side div elements the same height?

Basically what you do is make both divs/columns very tall by adding a padding-bottom: 100% and then "trick the browser" into thinking they aren't that tall using margin-bottom: -100% .

How do I make two divs the same height?

The two or more different div of same height can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. The used display property are listed below: display:table; This property is used for elements (div) which behaves like table.

How do I align two divs side by side?

The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.


1 Answers

Fiddle

What you do is make the right one absolutely positioned which stops its height influencing the parent's.

RELEVANT CSS

.container {
    background-color: gray;
    display: table;
    width: 70%;
    position:relative;
}

.container .left{
    background-color: tomato;
    width: 35%;
}

.container .right{
    position:absolute;
    top:0px;
    left:35%;
    background-color: orange;
    width: 65%;
    height:100%;
    overflow-y: auto;
}
like image 163
Hashbrown Avatar answered Oct 29 '22 16:10

Hashbrown