I want to customize a <cdk-virtual-scroll-viewport>
by using the CSS class .cdk-virtual-scroll-content-wrapper
so that the scroll container always shows a scrollbar. But my CSS code for this specific element is not applied (all other styles in the same component are working).
.cdk-virtual-scroll-content-wrapper {
overflow-y: scroll;
}
The behavior is not specific to this CSS property - if I set a border for example there is also no effect.
In the developer tools I can see the effective CSS, which lacks overflow-y
:
.cdk-virtual-scroll-content-wrapper {
position: absolute;
top: 0;
left: 0;
contain: content;
}
But if I change the CSS of the respective HTML element directly in the developer tools of the browser, the scroll bar is displayed.
Setting CSS for cdk-virtual-scroll-viewport
or cdk-virtual-scroll-viewport > div
doesn't work either:
cdk-virtual-scroll-viewport {
overflow-y: scroll;
}
I'm using Angular 10.2.2 with Sass.
How to apply CSS to .cdk-virtual-scroll-content-wrapper
?
index.html
. If you're inspecting element you'll find that sometimes styles are applied before your component. You also might need to use the!important
css option. – Wean