A Pen by Cole Brown on CodePen.
Created
December 19, 2020 22:01
-
-
Save melfis86/3dc3181cf9a1f78b75f0a80583a6ffd9 to your computer and use it in GitHub Desktop.
Product Slider & Carousel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="product-slider"> | |
<div class="product-slider__category"> | |
<h1>Product Category</h1> | |
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas faucibus sit amet augue vel scelerisque. Sed cursus lorem sit amet varius hendrerit. Integer venenatis mollis ipsum. Sed dapibus iaculis ex, non vestibulum tellus fringilla | |
sed. Maecenas eget molestie tellus.</p> | |
<a href="#">See all products</a> | |
</div> | |
<div class="product-slider__slider"> | |
<div class="product-slider__item"> | |
<img src="https://via.placeholder.com/175x250"> | |
<h3>greens+ whole body</h3> | |
<small>3 flavours / 4 sizes</small> | |
</div> | |
<div class="product-slider__item"> | |
<a href=""> | |
<img src="https://via.placeholder.com/175x250"> | |
<h3>greens+ whole body</h3> | |
<small>3 flavours / 4 sizes</small> | |
</a> | |
</div> | |
<div class="product-slider__item"> | |
<img src="https://via.placeholder.com/175x250"> | |
<h3>greens+ whole body</h3> | |
<small>3 flavours / 4 sizes</small> | |
</div> | |
<div class="product-slider__item"> | |
<img src="https://via.placeholder.com/175x250"> | |
<h3>greens+ whole body</h3> | |
<small>3 flavours / 4 sizes</small> | |
</div> | |
<div class="product-slider__item"> | |
<img src="https://via.placeholder.com/175x250"> | |
<h3>greens+ whole body</h3> | |
<small>3 flavours / 4 sizes</small> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".product-slider__slider").slick({ | |
infinite: false, | |
nextArrow: '<button type="button" class="slick-next">></button>', | |
prevArrow: '<button type="button" class="slick-prev"><</button>', | |
slidesToShow: 3, | |
slidesToScroll: 1, | |
swipeToSlide: true, | |
touchThreshold: 10, | |
responsive: [ | |
{ | |
breakpoint: 1024, | |
settings: { | |
slidesToShow: 2 | |
} | |
}, | |
{ | |
breakpoint: 768, | |
settings: { | |
slidesToShow: 3 | |
} | |
}, | |
{ | |
breakpoint: 650, | |
settings: { | |
slidesToShow: 2 | |
} | |
}, | |
{ | |
breakpoint: 475, | |
settings: { | |
slidesToShow: 1 | |
} | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
box-sizing: border-box; | |
} | |
.container { | |
margin: 0 auto; | |
max-width: 1200px; | |
} | |
.product-slider { | |
align-items: flex-start; | |
background: #eee; | |
display: flex; | |
flex-flow: row wrap; | |
@media (min-width: 768px) { | |
flex-flow: row nowrap; | |
} | |
} | |
.product-slider__category { | |
padding: 20px; | |
width: 100%; | |
@media (min-width: 768px) { | |
width: 35%; | |
} | |
} | |
.product-slider__slider { | |
width: 100%; | |
@media (min-width: 768px) { | |
width: 65%; | |
} | |
.slick-list { | |
padding-right: 80px; | |
position: relative; | |
} | |
} | |
.product-slider__item { | |
display: inline-block; | |
padding: 20px; | |
text-align: center; | |
img { | |
border: 1px solid #000; | |
margin: 0 auto; | |
} | |
&:hover { | |
background: rgba(0,0,0,.15); | |
} | |
} | |
// Slick Styles | |
.slick-arrow { | |
background: #97CC55; | |
border: 0; | |
color: #fff; | |
padding: 10px 15px; | |
position: absolute; | |
top: 50%; | |
transform: translateY(-50%); | |
z-index: 1000; | |
&.slick-prev { | |
left: 0; | |
} | |
&.slick-next { | |
right: 0; | |
} | |
&.slick-disabled { | |
display: none !important; //overrides slick defaults | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment