Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

placing a div next two divs above each other

Tags:

html

css

enter image description here

I want to place the 3 divs as shown in the photo div number 2 must stick to the bottom

here is what i have done: http://jsfiddle.net/GLHur/1/

like image 569
Sami Al-Subhi Avatar asked Aug 03 '12 13:08

Sami Al-Subhi


People also ask

How do I put divs above each other?

By using a div with style z-index:1; and position: absolute; you can overlay your div on any other div . z-index determines the order in which divs 'stack'. A div with a higher z-index will appear in front of a div with a lower z-index . Note that this property only works with positioned elements.

How do I make two divs sit next to each other?

With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this. With that, add height:100px and set margin.

How do I put 4 divs next to each other?

you can use flex property for, Display:flex apply flex layout to the flex items or children of the container only. So, the container itself stays a block level element and thus takes up the entire width of the screen. ...

How do you stack elements on top of each other?

Using CSS position property: The position: absolute; property is used to position any element at the absolute position and this property can be used to stack elements on top of each other. Using this, any element can be positioned anywhere regardless of the position of other elements.


3 Answers

Try this:

http://jsfiddle.net/GLHur/18/

<div class="con">
    <div id="div3"></div>
    <div id="div1_2">
        <div id="div1"></div>
        <div id="div2"></div>
    </div>
</div>

#div3{height:100px;width:100px;border: solid 1px #000; display:inline-block; background:red;}

#div1{height:30px;width:100px;border: solid 1px #000; position:absolute; top:0; background:blue;}
#div2{height:20px;width:100px;border: solid 1px #000; position:absolute; bottom:0; background:green;}

#div1_2{display:inline-block; vertical-align:top;}


.con { position:relative; }​
like image 191
Lowkase Avatar answered Sep 28 '22 09:09

Lowkase


This works:

    #div3{height:100px;width:100px;border: solid 1px #000;
display:inline-block;}
    #div1{height:30px;width:100px;border: solid 1px #000;}
#div2{height:20px;width:100px;border: solid 1px #000; position: absolute; bottom: 0}
#div1_2{display:inline-block;vertical-align:top; position: relative; height: 100px;}
like image 39
user1477388 Avatar answered Sep 28 '22 07:09

user1477388


Something like this?

http://jsfiddle.net/GLHur/6/


Or does the height change once you add content?

like image 24
Philip Kirkbride Avatar answered Sep 28 '22 08:09

Philip Kirkbride