Reputation: 4987
I'm using a jQuery plugin for the slider. It displays 3 items at a time, and adds a class slick-active
to the active items.
I want to display only the middle item as full width but want to display only 50% of the first and last items, as shown in the following image:
For that purpose, I am trying to set the absolute position of 50%, but it does not seem to work. I am unable to figure out how to set the position to get the above results.
This is what I'm trying:
.slick-active:first-child{
position: absolute;
left: -50%;
}
.slick-active:last-child{
position: absolute;
right: -50%;
}
Demo: http://jsfiddle.net/yu76xt4f/
Upvotes: 0
Views: 262
Reputation: 41832
I added the following CSS, which I don't recommend. as it is using !important
in it. I am using !important
to override the inline styling providing by the plugin.
CSS
.slick-slide.slick-active{
width: 100px !important;
}
.slick-slide.slick-active + .slick-slide.slick-active{
width: 400px !important;
}
.slick-slide.slick-active + .slick-slide.slick-active + .slick-slide.slick-active{
width: 100px !important;
}
Upvotes: 2
Reputation: 719
Try this, Use position: relative instead of absolute. and provide fixed value instead of percentage.
.slick-active:first-child{
position: relative;
left: -50px;
}
.slick-active:last-child{
position: relative;
left: -50px;
}
.slick-active {
position: relative;
left: -50px;
}
Upvotes: 0