Helloo,
I have a problem on my view using angular 4 and bootstrap 4. When I click on open to show calendar.
It's showing behind my modal.
I want to change z-index on its class but i don't have acces to the class because it's auto-generated.
How can i fix the probleme?
This is my code.
Thanks in advance.
Asked
Active
Viewed 1.2k times
3

Fatim
- 155
- 3
- 3
- 13
2 Answers
8
The issue is that bootstrap-modal sets z-index:1050
.modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
display: none;
overflow: hidden;
-webkit-overflow-scrolling: touch;
outline: 0;
}
The material date picker sets z-index: 1000
when the ckd-overlay-pane
is created
.cdk-overlay-pane {
position: absolute;
pointer-events: auto;
box-sizing: border-box;
z-index: 1000;
display: flex;
max-width: 100%;
max-height: 100%;
}
Adding this to your component style sheet should do the trick... but this will apply to all date-pickers in your entire project.
You will need to include a custom class identifier to make this specific to your modal date-picker if you only want to change that one.
::ng-deep .cdk-overlay-container mat-datepicker-content{ z-index:2000; }
Please reference the answer on this SO question for why using ::ng-deep
is ok until further notice.

Marshal
- 10,499
- 2
- 34
- 53
-
Thank u for your answer, but still the same problem! :/ – Fatim Nov 29 '18 at 08:05
-
2Hi @Marshal, it worked finaly by using ::ng-deep .cdk-overlay-container{ z-index:2000; }. thank u – Fatim Nov 29 '18 at 08:16
-
When I added this. My hover tab that has z-index 1050 starts to flicker really fast. – JayC Apr 21 '20 at 18:53
-
3This works for me as well ```::ng-deep .cdk-overlay-container { z-index:2000; }``` – Alex Guerreiro Aug 10 '20 at 18:16
0
Adding this to your component style sheet
.cdk-overlay-container { z-index: 1200 !important; }
-
Does this answer add anything to Marshal's accepted one from 2018 or [Alex Guerreiro's 2020 comment](https://stackoverflow.com/questions/53527964/mat-datepicker-toggle-showing-behind-modal/75533692#comment112012344_53528470)? – greybeard Mar 02 '23 at 08:48