-
React/Swiper 적용Language/React 2022. 10. 12. 11:19
module 추가
$ yarn add swiper
JSX Code
// Import Swiper React components import { Swiper, SwiperSlide } from 'swiper/react'; import SwiperCore, { Navigation, Pagination } from "swiper"; // Styles must use direct files imports import 'swiper/swiper.scss'; // core Swiper import 'swiper/modules/navigation/navigation.scss'; // Navigation module import 'swiper/modules/pagination/pagination.scss'; // Pagination module <Swiper className="mySwiper" pagination={true} modules={[Pagination]} > <SwiperSlide>Slide 1</SwiperSlide> <SwiperSlide>Slide 2</SwiperSlide> <SwiperSlide>Slide 3</SwiperSlide> </Swiper>
Css
.swiper { width: 100%; height: 100%; } .swiper-slide { text-align: center; font-size: 18px; background: #fff; /* Center slide text vertically */ display: -webkit-box; display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; -webkit-align-items: center; align-items: center; } .swiper-slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
참조)
'Language > React' 카테고리의 다른 글
React/createContext, useContext 사용하기 (0) 2022.10.12 React/AntV G2plot Chart 적용 (0) 2022.10.12 React/Jwt 연동 (access token, refresh token) (0) 2022.08.10 React/nth-check - Dependabot cannot update nth-check to a non-vulnerable version (0) 2022.08.10 React/redux & react-redux & redux-saga & etc (0) 2022.08.04