I want to add padding to the cells of my table when I click button View
, but this increases width of the cell. I've seen this question , this and this, however it still increases the size of the cell.
My CSS looks like this:
.move-right div {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
padding-left: 100px;
font-weight: bold;
max-width: 100%;
background-color: lightgreen;
}
And HTML:
<table class="table">
<thead>
<tr>
<th>Foo</th>
<th>Bar</th>
<th></th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let item of data">
<tr [ngClass]="{'move-right': item?.show == 1}">
<td>
{{ item.foo }}
</td>
<td>{{ item.bar }}</td>
<td>
<ul *ngIf="item.items && item.items.length > 0"
(click)="(item.show ? (item.show = 0) : (item.show = 1))">
{{ item.show ? 'Hide' : 'View' }}
</ul>
</td>
</tr>
<ng-container *ngIf="item.show==1">
<tr *ngFor="let num of item.items" class="move-right">
<td> <div>{{num}} </div> </td>
<td> <div>{{ num }}</div> </td>
<td> <div>{{ num }}</div> </td>
</tr>
</ng-container>
</ng-container>
</tbody>
</table>
This is a reproduced behavior at the stackblitz. Please click View
in the table to reproduce such behavior.
What I have now:
After View
button is clicked, then the width of columns became wider:
How to avoid of increasing cell width? I just would like to move text slightly to the right side of only td
which contains data 'a', 'b', 'c' and '1' and '2'., not in all cells.
It is not desirable to change the columns width on click along with that and I would like those 3 columns to move to the right on 80px?