CSS max-height property ignored by wrapper element

<div id="slide-table-wrapper">
<mat-table #slideTable class="fixed-height">
...
<div id="slide-table-wrapper">
<mat-table #slideTable class="fixed-height">
...
$max-table-height: calc(100% - 120px); // 120px is the height of the controls + paginator
mat-table.fixed-height {
max-height: $max-table-height;
overflow-y: auto;
}
$max-table-height: calc(100% - 120px); // 120px is the height of the controls + paginator
mat-table.fixed-height {
max-height: $max-table-height;
overflow-y: auto;
}
Result:
No description
No description
5 Replies
MC23
MC23OP23h ago
https://stackblitz.com/edit/sb1-pf2wz2nv here's the Stackblitz of a simplified example
Chris Bolson
Chris Bolson23h ago
I suspect that you will need to provide more details. Ideally in a "working" demo such as on Codepen or similar. That said, I do have a couple of questions/clarifications Presumably you are using scss. You are defining your .fixed-height as having a max height of calc(100% - 120px); Has the parent element got a defined height? To be able to calculate a value based on a percentage you need to have a defined parent value (in this case height). I presume that it is an Angular thing as "mat-table" is clearly not a valid HTML element. For it to work as is you would at very least need to define the element to be a block element as, I believe, browsers display non standard elements as inline. That is giving me a 404
MC23
MC23OP23h ago
I think it was private, now I set it to public In my real case, it's inside a <mat-dialog> which is tall 90vh, inside it there's a mat-card set to height: 100%; and inside the card-content there's this table with some controls above it. I'm trying to make the example similar to my real use case
Chris Bolson
Chris Bolson23h ago
I can't see to get stackblitz to update the preview with any of my changes, even no related ones. This is most likely due to my complete lack of knowledge of Angular. Have you tried adding display: block to the mat-table element? This does do the trick when I add it via dev tools.
MC23
MC23OP23h ago
Yeh I'm editing the css on devtools as well but it seems to work fine on the stackblitz, the mat-table is a material component and it comes with d-block property

Did you find this page helpful?