Reputation: 1282
I have this layout:
<div id="container">
<div id="left">LEFT</div>
<div id="mtop">MIDTOP</div>
<div id="mbotton">MIDBOT</div>
<div id="right">RIGHT</div>
<div id="botton">BOTTON</div>
</div>
#container {
height:200px;
width:300px;
vertical-align:middle;
display:table-cell;
background-color:yellow;
}
#left {
height:100px;
color:white;
background-color:blue;
font-size:20px;
width:100px;
}
#right {
height:100px;
color:white;
background-color:red;
font-size:20px;
width:100px;
}
#botton {
height:20px;
display: block;
vertical-align: botton color:white;
background-color:green;
font-size:20px;
width:100%;
}
#mtop {
height:50px;
color:white;
background-color:orange;
font-size:20px;
width:100px;
}
#mbotton {
height:50px;
color:white;
background-color:pink;
font-size:20px;
width:100px;
}
#left, #right {
display: inline-block;
vertical-align: middle
}
#mtop, #mbotton {
display: inline-block;
vertical-align: top
}
But I need this layout
Thanks for help me.
Upvotes: 2
Views: 1748
Reputation: 74048
When you move the #right
div above the #mtop
div, then you just need a float: left
for the #left
div and a float: right
for the #right
div
HTML:
<div id="container">
<div id="left">LEFT</div>
<div id="right">RIGHT</div>
<div id="mtop">MIDTOP</div>
<div id="mbotton">MIDBOT</div>
<div id="botton">BOTTON</div>
</div>
CSS:
#left {
float: left;
}
#right {
float: right;
}
You should also remove all those vertical-align
s and change
#container {
height:200px;
width:300px;
vertical-align:bottom;
display:table-cell;
background-color:yellow;
}
All div
s will then neatly align at the bottom of the #container
.
Modified JSFiddle
Upvotes: 2
Reputation: 5205
Wrap your middle divs in a parent div, and give the left, middle and right divs float: left
so they display next to each other.
CSS for middle div:
#middle {
width: 100px;
float: left;
}
See DEMO.
Upvotes: 3
Reputation: 249
You should create a <div>
to contain both MIDTOP
and MIDBOT
Better yet, avoid the Container <div>
altogether and use a <table>
with 0 px border.
Upvotes: 1