Answer the question
In order to leave comments, you need to log in
How to make an image slider that turns into a grid on mobile?
There is an image slider on a wordpress site that is displayed in a standard loop.
while ( $loop->have_posts() ): $loop->the_post(); ?>
<div>
<div class="img-wrapper">
<?php if ( has_post_thumbnail()) {
the_post_thumbnail('full','class=img-fluid');
} ?>
</div>
<?php endwhile; wp_reset_postdata(); ?>
Answer the question
In order to leave comments, you need to log in
Based on the thought of EvgenyMorozov , I found a solution, maybe someone will also find the thread useful (I'll give it briefly)
1. make such a wrapper - add the grid-row and grid-col classes to the frame , which will imitate the bootstrap grid.
<div class="slider grid-row" >
while ( $loop->have_posts() ): $loop->the_post(); ?>
<div class="grid-col">
<div class="img-wrapper">
<?php if ( has_post_thumbnail()) {
the_post_thumbnail('full','class=img-fluid');
} ?>
</div>
<?php endwhile; wp_reset_postdata(); ?>
</div>
{
breakpoint: 480,
settings: "unslick"
}
@media (max-width: 480px) {
.product-row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.product-col-6 {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
position: relative;
width: 100%;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
}
For example, add a condition
if(window.innerWidth > 600) {
$('.slider').slick({
slidesToShow: 3,
slidesToScroll: 3,
dots: true,
infinite: true,
cssEase: 'linear',
responsive: [
{
breakpoint: 480,
settings: "unslick"
}
]
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question