You can use display:flex
in a container father of divs
that will be with the table inside, so you leave the table with 100% of the width of this div
, whereas the div
which will have the table inside is 50% of the father’s width, so you will have 2 columns of 50% in the container father.
OBS: I just adjusted the columns of the most CSS stuff I didn’t move, and apart from the container parent does not include anything in your HTML, but remember to change the name of IDs
of each table when editing content
EDITE: Includes a table that occupies 100% of the width of container. For that I created a class w100
with width
100% and put in div
.box box.
Follow the image code above:
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
font: 75%/1.6 "Myriad Pro", Frutiger, "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", Verdana, sans-serif;
}
table {
border-collapse: collapse;
width: 100%;
border: 1px solid #666;
}
thead {
background: #ccc url(https://www.devfuria.com.br/html-css/tabelas/bar.gif) repeat-x left center;
border-top: 1px solid #a5a5a5;
border-bottom: 1px solid #a5a5a5;
}
tr:hover {
background-color: #3d80df;
color: #fff;
}
thead tr:hover {
background-color: transparent;
color: inherit;
}
tr:nth-child(even) {
background-color: #edf5ff;
}
th {
font-weight: normal;
text-align: left;
}
th,
td {
padding: 0.1em 1em;
}
.container {
display: flex;
flex-wrap: wrap;
}
.box {
box-sizing: border-box;
padding: 1rem;
width: 50%;
}
.box.w100 {
width: 100%;
}
<div class="container">
<div class="box">
<table id="Programa1">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box w100">
<table id="Programa2">
<thead>
<tr>
<th></th>
<th colspan="3">Programa</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Saude</td>
<td colspan="3"></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
I’m sorry, I didn’t understand your question, could you explain?
– Marcos Vinicius Leão
You just want to keep the tables separate from each other?
– Marcos Vinicius Leão
I need to display 10 tables, I want to display 5 on the left and 5 on the right. Basically that would be it.
– Guilherme Montagnani
The easiest method, what I have achieved so far is to let them side by side, but then they stick together, so if you can separate with a space already solves my problem.
– Guilherme Montagnani