Using Swiper to make navigation, click the Item Center

Source: Internet
Author: User

Purpose: Navigation has multiple, clicked item centered display.

Html:

<Divclass= "Swiper-container">    <Divclass= "Swiper-wrapper">        <Divclass= "Swiper-slide">Slider1</Div>        <Divclass= "Swiper-slide">Slider2</Div>        <Divclass= "Swiper-slide">Slider3</Div>        <Divclass= "Swiper-slide">Slider4</Div>        <Divclass= "Swiper-slide">Slider5</Div>        <Divclass= "Swiper-slide">Slider6</Div>        <Divclass= "Swiper-slide">Slider7</Div>        <Divclass= "Swiper-slide">Slider8</Div>        <Divclass= "Swiper-slide">Slider9</Div>    </Div></Div>

Js:

varMyswiper =NewSwiper ('. Swiper-container '), {    //autoplay:true,//optional option, Auto slideLooptrue,//Set Active Slide Center, there will be left and right left white phenomenon, add this will let the unfinished navigation before and after blankSlidetoclickedslide:true,//set to True then clicking Slide will transition to this slide. Slidesperview:5, Centeredslides:true,//when set to True, the active slide is centered instead of left in the default state. Spacebetween:10, Slidesoffsetbefore:0, Slidesoffsetafter:0,}) $('. Swiper-container. Swiper-slide '). On ("click",function(){    //myswiper.activeindex transition to the slide positionMyswiper.slideto (Myswiper.activeindex, 1000,false);//switch to the specified slide with a speed of 1 seconds    })

The style is not modified, and the active item is always displayed in the middle when only the effect is achieved.

Because of the time problem, no more time cloud to see the document, if there is a better way to remove the current center left and right left white question, welcome comments.

Using Swiper to make navigation, click the Item Center

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.