I'm writing an angular14 application.
I have a div
element that has cdkDrag
for it to be moveable, and behind it i have a few buttons and sliders and i noticed that the slider button is still visible when i drag that div on top of that slider.
i reproduced the issue on stackblitz with this template:
hello
<mat-slider
thumbLabel
tickInterval="1000"
step="1000"
min="0"
max="100000"
aria-label="units"
></mat-slider
>goodbye
<div
cdkDrag
style="background-color: white;
border: 1px solid black; padding: 5em;
position: relative; bottom: 40px;">
hello
</div>
i tried changing z-index
of that div but results are the same.
any ideas how to resolve the issue?
You are on the right track with z-index. You just need to set on the right classes and in the right css.
styles.css
.mat-slider-thumb {
z-index: 0 ;
}
.myDiv{
z-index: 1;
}
html
...
<div class="myDiv"
cdkDrag
...
As this can be a bit confusing if you have other sliders, add a class on this one, so you can be more precise in the styling