简体   繁体   中英

How to show on the carousel a piece of the previous and next slide?

I'm beginner in ReactJS and I would like to render the slides of my carousel showing a piece of the previous slide and also of the next slide, what I need to do is like this in the example below:

在此处输入图像描述

I am currently using the react-elastic-carousel library, but I am not attached to it, any library that works in ReactJS I am willing to use. Currently in my code, the slide is showing 100% of the space.

Here's my code I put into codesandbox.io :

 import React from "react"; import "./styles.css"; import Carousel from "react-elastic-carousel"; export default function App() { return ( <div className="App"> <Carousel itemsToShow={1} initialActiveIndex={3}> <div className="div">1</div> <div className="div">2</div> <div className="div">3</div> <div className="div">4</div> <div className="div">5</div> <div className="div">6</div> <div className="div">7</div> </Carousel> </div> ); }

Thank you in advance for the help

I was able to show some of the previous and next slides by changing the overflow on the slider-container:

.rec.rec-slider-container {
  overflow: visible;
}

I would also put overflow-x: hidden; on your body so that it doesn't scroll left and right.

codesandbox.io

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM