Our current table looks like this: https://i.sstatic.net/eUyBB.png
The first row has a background color and the second row is white - which is correct.
Now I would like to align the attributes to the right. I added the following code to the table:
.table-wrapper tbody {
font-size: 1.5rem;
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 0 24px;
}
The current result looks like this: https://i.sstatic.net/YuYcb.png
But there is an issue. I need the result to look something like this: https://i.sstatic.net/J8eVD.png
Can someone help me fix our code?
$(document).ready(function()
{
$("tr:odd").css({
"background-color":"#000",
"color":"black"});
});
.additional-attributes tr th {
border-right: 0px solid #ccc;
font-weight: 200;
width: 0%;
}
additional-attributes tbody tr {
border-bottom: 0px solid #ccc !important;
border-bottom: none !important;
}
additional-attributes tr {
border-bottom: 0px solid #ccc !important;
}
.table-wrapper {
float: left;
margin-top: 10px;
}
.additional-attributes tr td {
font-weight: 500;
padding: 10px 10px;
}
tbody tr:nth-child(odd){
background-color: #f8fafb;
color: black;
}
.table-wrapper tbody {
font-size: 1.5rem;
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 0 24px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="additional-attributes-wrapper table-wrapper">
<table class="data table additional-attributes" id="product-attribute-specs-table">
<tbody>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
<tr>
<th class="label" scope="row">Parametr</th>
<td class="data">first</td>
</tr>
</tbody>
</table>
</div>
Updated code:
<style>
.seller-attributes {
box-sizing: border-box;
height: auto;
padding: 15px;
}
.additional-attributes tr th {
border-right: 0px solid #ccc;
font-weight: 200;
width: 0%;
}
additional-attributes tbody tr {
border-bottom: 0px solid #ccc !important;
border-bottom: none !important;
}
additional-attributes tr {
border-bottom: 0px solid #ccc !important;
}
.table-wrapper {
float: left;
margin-top: 10px;
}
.additional-attributes tr td {
font-weight: 500;
padding: 10px 10px;
}
tbody tr:nth-child(odd){
background-color: #f8fafb;
color: black;
}
/* ADDED */
tbody tr:nth-of-type(4n + 3), tbody tr:nth-of-type(4n){
background-color: white;
}
tbody tr:(even){
padding-left: 24px;
}
.additional-attributes tbody tr {
display: grid;
grid-template-columns: 2fr 1fr;
}
.additional-attributes tr th {
width: 100%
}
</style>