I am trying to create a CSS Table based layout which has an even spacing/border around each table cell and making sure that the table-cells are always the same height. Here is an example of what I am trying to achieve:
My HTML currently looks like this:
.two-col.body-width {
max-width: 1138px;
}
.two-col {
display: table;
clear: both;
margin: 0 auto;
padding: 20px 0;
width: 100%;
box-sizing: border-box;
border-spacing: 25px 0px;
}
.two-col > .col_container.align-top {
vertical-align: top;
}
.layout .section-tout {
position: relative;
padding: 20px 40px 48px;
background: #f4f4f3;
border-left: 5px solid #da202a;
}
.two-col > .col_container {
width: 50%;
display: table-cell;
text-align: left;
vertical-align: middle;
box-sizing: border-box;
}
<section class="layout two-col body-width">
<div class="col_container align-top section-tout">
<!-- content goes here -->
</div>
<div class="col_container align-top section-tout">
<!-- content goes here -->
</div>
</section>
Here is a working example: https://jsfiddle.net/grzkgdp3/1/
What I have here is almost perfect, but as you can see from the image I updated I need the spacing / border to be doubled in the middle and I cannot see an intelligent way of doing this.
I can see a solution where I used border: 25px solid white;
on the tabel-cell. This solves my spacing issue but because I need the red border on the left, I then have to apply this using the :after
pseudo element which makes things a bit messy.
If anyone has a solid solution that can help it would be great to hear it.
Cheers!
Update
Unfortunately I cannot use a flexbox
solution as I need to support all modern browser and IE9 and above.