I am trying to create a grid struture with div of equal height and width but I am unable to apply the border
CSS
.Container {
width:1000px;
position:relative;
margin:0 auto;
}
.RowContainer {
overflow:hidden;
position:relative;
height:200px;
clear:both;
}
.RowContainer .Cell {
position:relative;
float:left;
height:100%;
width:200px;
border:1px solid Black;
}
HTML
<div class="Container">
<div class="RowContainer">
<div class="Cell"><h1>lorum ipsum lorum ipsum</h1><p>lorum ipsum epsum</p> </div>
<div class="Cell"><h1>lorum ipsum</h1><p>lorum ipsum epsum</p></div>
<div class="Cell"><h1>lorum ipsum lorum ipsum</h1><p>lorum ipsum epsum
</p> </div>
<div class="Cell"><h1>lorum ipsum</h1><p>lorum ipsum epsum</p></div>
</div>
<div class="RowContainer">
<div class="Cell"><h1>lorum ipsum lorum ipsum</h1><p>lorum ipsum epsum
</p></div>
<div class="Cell"><h1>lorum ipsum</h1><p>lorum ipsum epsum</p></div>
<div class="Cell"><h1>lorum ipsum</h1><p>lorum ipsum epsum</p></div>
<div class="Cell"><h1>lorum ipsum</h1><p>lorum ipsum epsum</p></div>
</div>
<div style="clear:both"></div>
</div>
I have two issues
1.
border is not showing in the last row.
2.
As well as the border width seems unequal despite of applying same border property to all.
Bottom border is not showing in either row because you have
height: 100%on the.Cellandoverflow: hiddenon the.Container. What you are seeing under the first row is the top border for the second row.If you set
height: 100%;on the child of an element ofheight: 200pxthat hasoverflow: hiddenand then you set aborderof1pxto that child, then that border adds up on all sides.It makes that child element take up
202pxvertically. That’s1pxfrom top border +200pxfrom height +1pxfrom bottom border.But the parent element has a height of only
200pxandoverflow: hidden, which means that vertically, from the child element, what you see is the1pxtop border and199pxof the child’s height. There is still1pxof its height and the1pxbottom border which are hidden.Second vertical border is thicker than the first, because you have there both the right
1pxborder of the first cell and the left1pxborder of the second cell.This would solve the issue http://dabblet.com/gist/3145644