[FlexSlider 2] How to show a peek of the slides on both sides
![[FlexSlider 2] How to show a peek of the slides on both sides](img/ogp.png)
Here's a sample showing how to display a peek of the slides on both sides using the jQuery slider plugin "FlexSlider 2".
Sample
When viewed on a PC, you can see a peek of the slides on both sides.
HTML
Wrap FlexSlider with <div class="flexslider_wrap">.
<div class="flexslider_wrap">
<div class="flexslider">
<ul class="slides">
<li><img src="img01.jpg"></li>
<li><img src="img02.jpg"></li>
<li><img src="img03.jpg"></li>
<li><img src="img04.jpg"></li>
</ul>
</div>
</div>
JS
Execute FlexSlider as usual.
$(".flexslider").flexslider({
animation: "slide"
});
CSS
Write CSS like the following.
Please change "max-width" on line 5 as appropriate.
.flexslider_wrap {
overflow: hidden;
}
.flexslider_wrap .flexslider {
max-width: 640px;
margin-left: auto;
margin-right: auto;
}
.flexslider_wrap .flexslider .flex-viewport {
overflow: visible!important;
}
By changing "max-width" on line 5 as appropriate, you can also support squares and other shapes.
Notes
When viewed on smartphones, seeing just a peek of both sides can look strange.

In this case, if the slider width falls below 640px, it will look like this, so
It might be a good idea to limit it to screen widths where the slider width is 640px or more using media queries.
@media screen and (min-width: 660px) { /*Screen width where the slider width is 640px or more*/
.flexslider_wrap {
overflow: hidden;
}
.flexslider_wrap .flexslider {
max-width: 640px;
margin-left: auto;
margin-right: auto;
}
.flexslider_wrap .flexslider .flex-viewport {
overflow: visible!important;
}
}
Comments
We also welcome reports such as "It worked!".








If this was helpful, we appreciate your support!
Your support will be used for childcare.
Or support us by buying something from the buttons below
(You don't have to buy the linked product.)
Amazon
Rakuten Ichiba
Yahoo! Shopping
PR