I am facing an issue with the layout of my HTML table. I have set space between each cell using margin, but this is causing a problem with column width. Instead of having col-12
for a row, it has become col-11
due to the spacing. This has resulted in the header row spanning the full width while the data rows are not aligned properly. How can I adjust the header row to match the width of the data rows?
https://i.sstatic.net/fJbKk.jpg
.event-col {
border-radius: 10px;
box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3);
background-color: #fff;
padding: 10px;
margin: 2px;
display: inline-block;
}
.event-col-header {
padding: 10px;
margin: 2px;
display: inline-block;
border: 0px !important;
font-weight: bold;
font-family: IRANSans;
}
.event-row {
border-radius: 10px;
box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3);
background-color: #c1d2fe;
margin: 10px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="03616c6c77707771627343372d352d32">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="row">
<div class="col-12">
<table id="example" class="table dt-responsive nowrap showborder ">
<tr class="event-row mb-1">
<th class="col-1 event-col-header">No</th>
<th class="col-2 event-col-header">Name </th>
<th class="col-1 event-col-header">Date</th>
<th class="col-2 event-col-header">Hour</th>
<th class="col-5 event-col-header">Address</th>
</tr>
<tr>
<td class="col-1 event-col">@counter</td>
<td class="col-2 event-col">@item.Name</td>
<td class="col-1 event-col">@item.EventDate</td>
<td class="col-2 event-col"> @item.StartTime </td>
<td class="col-5 event-col">@item.Address</td>
</tr>
</table>
</div>
</div>