splide icon indicating copy to clipboard operation
splide copied to clipboard

How i can set styles to center focus slide.

Open cristobaljms opened this issue 5 years ago • 8 comments

i want to do this example in react.js, where de center card change his style but i dont know how.

image

cristobaljms avatar Jan 29 '21 14:01 cristobaljms

I found a css solution (but I'm not shure if there is a better solution): ".splide__slide.is-active" is the active slide

Please add this style code after the original used stylesheet (<link rel="stylesheet" type="text/css" ...)

<style>
.splide__slide{
  transform: scale(0.8, 0.8); /* sets all slides to a scaling of 0.8 (80%) */
  display: inline-flex;  /* used for all slides vertical align center */
  vertical-align: middle; /* used for all slides vertical align center */
}
.splide__slide.is-active{
  transform: scale(1, 1); /* sets the active slide to scaling of 1 (100%) */
}
</style>

cybaer6 avatar Jan 30 '21 10:01 cybaer6

Use classes: https://splidejs.com/options/ i define this classes: { // Add classes for arrows. arrows: 'splide__arrows arrow', arrow: 'splide__arrow arrow', prev: 'splide__arrow--prev arrow', next: 'splide__arrow--next arrow', // pagination: 'splide__pagination position', // container page: 'splide__pagination__page position', // each button } And i change the style like this .slider .arrow svg { fill: #d25252; font-size: 10px; } .slider .position.is-active { background-color: #d25252; } .slider .position:hover { background-color: #7a7a7a; }

AdrigomRoc avatar Feb 04 '21 17:02 AdrigomRoc

Sorry, but I can't help you in react.js (A JavaScript library for building user interfaces found at https://reactjs.org/

cybaer6 avatar Feb 07 '21 14:02 cybaer6

There is a bug when focus:center is active. SplideSlide's lost classes when you drag the first element and sometimes other splides dont update their class.

deepin-screen-recorder_Select area_20210311132124

Update: this are my options:

  {
    type:"loop",
    perPage: 3,
    perMove: 1,
    pagination: false,
    arrows: false,
    focus: 'center',
   } 

subgero avatar Mar 11 '21 19:03 subgero

Close the issue due to the major version update. Feel free to create a new issue or open a new discussion.


To style the active slide, use the is-active class. In v3, is-prev and is-next are also available. But I don't recommend scaling .splide__slide elements. Add an element in a slide, and style it alternatively.

<li class="splide__slide">
  <div class="inner">
  </div>
</li>
.splide__slide.is-active .inner {
  transform: scale( 1.2 );
}

NaotoshiFujita avatar Oct 09 '21 15:10 NaotoshiFujita

НаотошиФуджита, Спасибо Вам огромное!) долго не мог решить эьу проблему)

Daniil-333 avatar Sep 19 '23 09:09 Daniil-333

Use classes: https://splidejs.com/options/ i define this classes: { // Add classes for arrows. arrows: 'splide__arrows arrow', arrow: 'splide__arrow arrow', prev: 'splide__arrow--prev arrow', next: 'splide__arrow--next arrow', // pagination: 'splide__pagination position', // container page: 'splide__pagination__page position', // each button } And i change the style like this .slider .arrow svg { fill: #d25252; font-size: 10px; } .slider .position.is-active { background-color: #d25252; } .slider .position:hover { background-color: #7a7a7a; }

splide classes config here: https://splidejs.com/guides/options/#classes

abdulrahman-mh avatar Sep 10 '24 18:09 abdulrahman-mh

Close the issue due to the major version update. Feel free to create a new issue or open a new discussion.

To style the active slide, use the is-active class. In v3, is-prev and is-next are also available. But I don't recommend scaling .splide__slide elements. Add an element in a slide, and style it alternatively.

  • .splide__slide.is-active .inner { transform: scale( 1.2 ); }

    This was really helpful. I was scaling the .splide__slide elements and it was giving issues, until I came across this fix. Thanks @NaotoshiFujita

    idmcalculus avatar Apr 04 '25 13:04 idmcalculus