I'm currently faced with a challenge involving an Angular Material table containing numerous columns. My goal is to selectively hide certain columns based on specific CSS media queries.
This is the code snippet I have experimented with so far:
HTML:
<ng-container matColumnDef="Speed">
<th mat-header-cell *matHeaderCellDef>Speed</th>
<td mat-cell *matCellDef="let row" class="mat-cell">
<span class="speed" [ngClass]="{ 'bold': selectedSpeedNames.includes(speed.name) }" *ngFor="let speed of row.speed.$values">{{ speed.name }}</span>
</td>
</ng-container>
CSS:
@media only screen and (max-width: 768px) and (min-width: 480px) {
th[mat-header-cell*="Speed"],
td[mat-cell*="Speed"] {
display: none !important;
}
}
I've attempted to utilize the CSS media query to conceal the "Speed" column on smaller screens (ranging from 480px to 768px), but unfortunately, it does not seem to be achieving the desired outcome. The column remains visible instead of being hidden.
What could I be missing or doing incorrectly in this scenario? Is there a more effective method to accomplish this functionality? Any assistance or recommendations provided would be highly valued. Thank you!