question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Center Mode Z Index

See original GitHub issue

center mode z-indexing stays sequential

I am attempting to use center mode with a box shadow but due to the zindexing of the slides, I cannot get the center slide in-front of all slides. I am attempting to create this carousel.

====================================================================

[ paste your jsfiddle link here ]

use this jsfiddle to reproduce my bug: http://jsfiddle.net/zL17w28f/3/

====================================================================

Steps to reproduce the problem

  1. Set centerMode: true and slidesToShow: 3
  2. Add a box-shadow to .slick-slide

====================================================================

What is the expected behaviour?

That in center mode, the z-index of the center slide is the highest.

====================================================================

What is observed behaviour?

When in center mode, z index ordering stays sequential.

====================================================================

More Details

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
hjelmeircommented, Dec 29, 2017

I was able to hack this with css.

// Need position relative and a base z index
.slick-slide {
    position: relative;
    z-index: 6;
}
// Set center to high zindex
.slick-center {
    z-index: 999; // or any high #
}
// Target slide after center to keep stacking
.slick-center + .slick-slide {
    z-index: 8;
}
3reactions
EstiTcommented, Mar 12, 2021

I know this post is for almost 3years ago. but if you add this class to your project, I think your problem will solve

.slick-slide {
    position: relative;
    z-index: 1;
}

.slick-active {
    transform: scale(1.2);
    z-index: 2;
}

I had to add improtant to get it to work. Also, .slick-active made multiple images larger, not just the center. I ended up using:

.slick-center {
    transform: scale(1.2);
    z-index: 2 !important;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

z-index - CSS: Cascading Style Sheets - MDN Web Docs
The z-index CSS property sets the z-order of a positioned element and its descendants or flex items. Overlapping elements with a larger ...
Read more >
Centering Image with Z-Index in a Resizable Window?
I was using relative positioning, but after moving to absolute, it aligns to the left. How can I center it, even if window...
Read more >
CSS z-index property - W3Schools
The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element...
Read more >
Z-index and stacking contexts - web.dev
In this module find out how to control the order in which things layer on top of each other, by using z-index and...
Read more >
How does Z-index property work in CSS with Examples
Here we discuss the introduction to CSS z-index along with how does Z-index ... left: 0px; top: 0px; z-index: -10; } h1 {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found