Front-End & Daily

[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

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.

FlexSlider 2 Smartphone

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!".

After reviewing the content, we will publish it, omitting personal information.

Enter your name and email address

Please enter if you would like a reply by email.

The personal information provided will not be disclosed. It will only be used for replies.

It will be sent directly. Please confirm and "Send".

If this was helpful, we appreciate your support!
Your support will be used for childcare.

Send support via OFUSE


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

As an Amazon Associate, "Ken" earns income from qualifying purchases.

Share

Share on Twitter Share on Facebook Share on LINE Share on Hatena Bookmark