Here is the solution to solve your issue:
thead th {
position:relative;
}
thead th:before {
content: '';
position: absolute;
height: calc(100% + 2px);
width: calc(100% + 2px);
border: 1px solid black;
top: -1px;
left: -1px;
pointer-events: none;
}
It's important to note that JavaScript is not responsible for transforming borders. The actual problem lies in the fact that the borders do not belong to the <th>
element due to collapsing.
When rendering, the browser accounts for adjacent elements to calculate combined borders. However, these borders are placed based on the original DOM structure and not affected by any transformations applied to <th>
elements.
An easy fix is using the :before
pseudo-element to render the borders.
Another approach would be overriding
border-collapse: collapse;
on your <table>
, as defined in bootstrap.css
.
But keep in mind that this change will cause your table borders to no longer collapse (combine), which may not be desired.