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.
相关问题
- Angular RxJS mergeMap types
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Adding a timeout to a render function in ReactJS
- How to update placeholder text in ng2-smart-table?
-
Why does the box-shadow property not apply to a
The perceived padding is being caused by
display: table-cell;
andvertical-align: inherit;
(which usually is valuemiddle
) from the default browser/user-agent<td>
styles in combination with aheight
being set on thetr.mat-row
. The<tr>
with CSS class.mat-row
has a set height by default of48px
. You can adjust the height or set toheight: auto;
then adjust padding to thetd.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.Here is a StackBlitz showing the
height: auto;
ontr.mat-row
as well as a custom padding value ontd.mat-cell
in action.While I'd recommend to avoid changing the
display
property value ontd.mat-cell
, you can change it to something likeinline-block
to see the effects without any adjustments toheight
ofmat-row
.