简体   繁体   中英

How to get width form keen-slider/react

I need to know the width of each slide in the carousel to make the height the same. That way every element of the slider will be square.

在此处输入图像描述

I tried to find information in the documentation. I didn't find anything I needed.

I got this solution

const [ref, internalSlider] = useKeenSlider({...})
const slideHeight = internalSlider.current?.slides?.[0]?.clientWidth;

<div ref={ref} className="keen-slider">
      {slides.map(slide => (
        <div style={{ height: slideHeight }}/>
      )}
</div>

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