I have a table section as below. I want that wherever I have "col" attribute a margin of 20px should be added on the left. I just need help with the syntax for this.
I have edited the question and included my complete code here. Please note that in the mobile view each row is stacked on top another.
<div class="tableComponent">
<table class="table table-striped" id="table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Designation</th>
<th scope="col">Contact Details</th>
</tr>
</thead>
<tbody>
<tr>
<td col="Name">Mark</td>
<td col="Designation">Otto</td>
<td col="Contact Details">@mdo</td>
</tr>
<tr>
<td col="Name">Mark</td>
<td col="Designation">Otto</td>
<td col="Contact Details">@mdo</td>
</tr>
<tr>
<td col="Name">Mark</td>
<td col="Designation">Otto</td>
<td col="Contact Details">@mdo</td>
</tr>
<tr>
<td col="Name">Mark</td>
<td col="Designation">Otto</td>
<td col="Contact Details">@mdo</td>
</tr>
</tbody>
</table>
</div>
CSS
.tableComponent table{
font-family: 'Poppins';
font-size:12px;
width: 50%;
border-collapse: separate;
}
.tableComponent table thead th{
border-bottom: 0px;
}
.tableComponent table td,th{
border-top: 0px;
}
.tableComponent .table-striped tr:nth-child(even){
background-color:#F8F8F8
}
.tableComponent tr{
border: hidden;
}
@media all and (max-width: 500px){
.tableComponent table{
width: 90%;
margin-left: 5vw
}
.tableComponent thead {
display: none;
}
.tableComponent tr {
display: flex;
flex-direction: column;
margin-bottom: 5px;
}
.tableComponent td::before {
content: attr(col);
font-weight: bold;
}
.tableComponent td[col]{
padding-right: 5rem;
}
}
I don't know how to write this. Any suggestions?
content: '';