<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
<div class="wrap">
<div class="slider">
<div class="item">
<img src="https://upload.wikimedia.org/wikipedia/commons/d/d1/Mount_Everest_as_seen_from_Drukair2_PLW_edit.jpg" alt="">
</div>
<div class="item">
<img src="https://cdn.britannica.com/67/19367-050-885866B4/Valley-Taurus-Mountains-Turkey.jpg" alt="">
</div>
<div class="item">
<img src="https://peakvisor.com/img/news/mount_fuji.jpg" alt="">
</div>
<div class="item">
<img src="https://images.squarespace-cdn.com/content/v1/551bea30e4b07646122d9190/1562066896810-YNF3ST3DWCEPPF28SN0G/ke17ZwdGBToddI8pDm48kO9gALA8zh99qKQGCnsE5xkUqsxRUqqbr1mOJYKfIPR7LoDQ9mXPOjoJoqy81S2I8N_N4V1vUb5AoIIIbLZhVYxCRW4BPu10St3TBAUQYVKc_-np3OzCnTIqZc-TKEgg8EWz2x1JQ41VwUcPlua8L8IxIR4lET3-slYj7CxS3GkY/Panorama+1.jpg" alt="">
</div>
</div>
</div>
* {
box-sizing: border-box;
}
img {
max-width: 100%;
width: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.wrap {
position: relative;
z-index: 100;
width: 100%;
height: 100%;
padding: 0 60px;
background: #60b58a;
overflow: hidden;
}
.wrap:after {
content:'';
position: absolute;
z-index: 2;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,.5);
}
.slider {
position: relative;
z-index: 200;
padding: 0 0px;
margin: 5rem auto;
max-width: 800px;
width: 100%;
}
.slick-arrow {
position: absolute;
top: 50%;
width: 40px;
height: 50px;
line-height: 50px;
margin-top: -25px;
border: none;
background: transparent;
color: #fff;
font-family: monospace;
font-size: 5rem;
z-index: 300;
outline: none;
}
.slick-prev {
left: -50px;
text-align: left;
}
.slick-next {
right: -50px;
text-align: right;
}
.item.slick-slide {
width: 400px;
height: 400px !important;
transition: transform .5s ease;
position: relative;
}
.slick-slide:after {
content:'';
position: absolute;
z-index: 2;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,.5);
transition: transform .4s;
}
.item.slick-slide {
transform: scale(0.7) translate(640px);
}
.item.slick-slide.slick-center + .slick-slide {
transform: scale(0.8) translate(-250px);
z-index: 10;
}
.item.slick-slide.slick-center + .slick-slide + .item.slick-slide {
transform: scale(0.7) translate(-640px);
z-index: 5;
}
.item.slick-slide.slick-active {
transform: scale(0.8) translate(250px);
}
.item.slick-slide.slick-center {
/* margin: 0 -10%; */
transform: scale(1);
z-index: 30;
}
.slick-center:after {
opacity: 0;
margin:10px;
padding:10px;
}
$('.slider').slick({
slidesToShow: 3,
slidesToScroll: 1,
arrows: true,
dots: false,
centerMode: true,
variableWidth: true,
infinite: true,
focusOnSelect: true,
cssEase: 'linear',
touchMove: true,
prevArrow:'<button class="slick-prev"> < </button>',
nextArrow:'<button class="slick-next"> > </button>',
// responsive: [
// {
// breakpoint: 576,
// settings: {
// centerMode: false,
// variableWidth: false,
// }
// },
// ]
});
var imgs = $('.slider img');
imgs.each(function(){
var item = $(this).closest('.item');
item.css({
'background-image': 'url(' + $(this).attr('src') + ')',
'background-position': 'center',
'-webkit-background-size': 'cover',
'background-size': 'cover',
});
$(this).hide();
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.