Reputation: 1404
I have created a simple example of 3 columns, here if one expands the other two will also expand.
Below is the HTML code
<div id="outer">
<div id="inner">
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
</div>
<div id="inner">
Hello world!
</div>
<div id="inner">
Hello world!
</div>
</div>
CSS code
#outer {
width:500px;
background:#FFCCCC;
}
#inner {
background:#FFCC33;
padding:10px;
width:100px;
margin-left:25px;
display:table-cell;
border:1px solid #F00;
}
JSFiddle http://jsfiddle.net/KCzq3/6/
Update:
see in the html if you increase the conent of one div the other two divs will show the same height of the maximum high div, now if table-cell doesn't works, what can be the solution for this i cannot give float or inline block or it will shrink
Upvotes: 3
Views: 74
Reputation: 105873
if you use the display:table
/table-cell
layout, then you should use border-spacing
to set margin
/space in between elements DEMO
Upvotes: 2
Reputation: 3491
use inline-block
instead of table-cell
HTML
<div id="outer">
<div class="inner">
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
</div>
<div class="inner">
Hello world!
</div>
<div class="inner">
Hello world!
</div>
</div>
CSS
#outer {
width:500px;
background:#FFCCCC;
display: table;
}
.inner {
background:#FFCC33;
padding:10px;
width:100px;
margin-left:25px;
display:inline-block;
border:1px solid #F00;
}
if you want to have divs with the same heights so:
change the #outer
style to this :
#outer {
width:500px;
background:#FFCCCC;
border-collapse: separate;
display: table;
border-spacing: 12.5px 0;
}
Upvotes: 0
Reputation: 186
If you use display:table-cell
the div acts like a table and responds to table commands.
Simply put this in #outer instead, to simulate the cell-spacing effect:
border-spacing:25px 0;
border-collapse:separate;
Upvotes: 4
Reputation: 721
HTML
<div id="outer">
<div class="inner">
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
</div>
<div class="inner">
Hello world!
</div>
<div class="inner">
Hello world!
</div>
</div>
CSS
#outer {
width:500px;
background:#FFCCCC;
display: table;
}
#outer:hover {
width: 750px;
}
.inner {
background:#FFCC33;
padding:10px;
width:100px;
margin-left:25px;
display:table-cell;
border:1px solid #F00;
}
Normal State
On Hover
You see, on hover, all of the inner class will expand to width:750px
due to the display: table
CSS property.
Upvotes: -1