When I inspect the element with developer tools it shows zero padding, but when I look a it and mouse over it, it very clearly has padding within the cell. I have no idea where this is coming from, and setting td { padding: 0 !important }
does nothing.
The perceived padding is being caused by display: table-cell;
and vertical-align: inherit;
(which usually is value middle
) from the default browser/user-agent <td>
styles in combination with a height
being set on the tr.mat-row
. The <tr>
with CSS class .mat-row
has a set height by default of 48px
. You can adjust the height or set to height: auto;
then adjust padding to the td.mat-cell
as needed. This effectively removes the perceived padding that is visible when inspecting with developer tools. The green padding visualization seen in something like Chrome developer tools when inspecting the <td>
is how just a middle vertically aligned element with table-cell is displayed in the tools. If you examine the Computer properties of that <td>
you'll see it has zero padding on all four sides.
.mat-row {
height: auto;
}
.mat-cell {
padding: 8px 8px 8px 0;
}
Here is a StackBlitz showing the height: auto;
on tr.mat-row
as well as a custom padding value on td.mat-cell
in action.
While I'd recommend to avoid changing the display
property value on td.mat-cell
, you can change it to something like inline-block
to see the effects without any adjustments to height
of mat-row
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.