I am trying to make two panels which can be opened and closed by two buttons.
FIDDLE
All is working fine, when I do like this:
In this case red panel is hiding behind green during animation.
But when I do like this:
The green panel always in front of red panel during animation.
But the first opened panel has z-index: 9
and the second opened one has z-index: 10
.
Please, help me to solve the problem.
The reason why it goes above it is due to the html. the red was created before the green so the only way to make them animate 'underneath' each other every time would be to edit the z-index programmatically through the if statements
In the if statements just change z-index :
if ($messengerPanel.hasClass('open')) {
sidebarPanelClose($messengerPanel);
$("#green").css("z-index", "1");
} else {
sidebarPanelOpen($messengerPanel);
$("#green").css("z-index", "10");
}
Same for red too ...
Updated fiddle : http://jsfiddle.net/rcotjr5y/4/
check whether it will work include in css
.open-first{
z-index:-1 !important;
}
.open{
z-index:1;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With