I am looking to create a row of buttons within a table, where each button is represented by an image and has a transparent border/background.
To achieve this, I placed each button in one of the 10 remaining cells of a table using
<td class="col-sm-1">
and attempted to ensure that the images are set to cover. However, I encountered an issue where the border did not align with the border of the image in the line above:
button.transparent {
background: transparent;
border: none !important;
}
.gborder {
border: 4px solid green;
/* outline: 2px solid white; */
}
.selectedTD {
background-color: grey !important;
border-bottom: 2pt solid grey;
}
span.smallText {
color: white;
font-size: 70%;
}
.imgButton {
cursor: pointer;
background-size: cover;
/* background-size: contain; */
background-repeat: no-repeat;
width: 100%;
height: 100%;
min-height: 48px;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c1e1313080f080e1d0c3c49524c524e">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e6c61617a7d7a7c6f7e4e3b203e203c">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<table class="table table-striped table-hover caption-top">
<tbody id="table">
<tr>
<td class="col-sm-2">
<h5 class="text-start">click for details:</h5>
</td>
<td class="col-sm-1 ">
<button class="transparent" disabled>
<img src="image-url.jpg"
class="gborder imgButton">
</button>
</td>
... [remaining code here]
</tr>
... [additional rows of code]
</tbody>
</table>
Additional information:
- The first line ("click for details") always consists of 1
col-sm-2
entry and 10col-sm-1
entries. - The second line always contains 2
col-sm-2
entries and 7col-sm-1
entries. - The aspect ratio of the images must be maintained.
How can I ensure that the border of the second line aligns with the first line when the browser window size changes? Specifically, I would like the image in the second line with the col-sm-2
class to occupy exactly 2 items, while maintaining consistent border alignment throughout.