1. HTML
2. CSS
.container {
position: relative;
}
.container .bg-left {
width: 50%;
height: 100%;
background-color: salmon;
position: absolute;
top: 0;
left: 0;
}
.container .bg-right {
width: 50%;
height: 100%;
background-color: royalblue;
position: absolute;
top: 0;
right: 0;
}
.container .inner {
position: relative;
margin: 0 auto;
width: 250px;
height: 150px;
background-color: orange;
}
옵션은 객체데이터를 사용하여 입력
direction : 방향 설정
autoplay: 자동재생 여부
loop: 반복재생 설정
SlidesPerView: 한번에 보여줄 슬라이드 개수 지정
spaceBetween: 슬라이드 사이의 거리(px)
centeredSlides: active(활성) 슬라이드 중앙 배치 설정
pagination: 페이지번호 설정
navigation: 탐색버튼 설정
<예시>
// new Swiper(선택자, 옵션)
new Swiper('.notice-line .swiper-container', {
direction: 'vertical',
autoplay: true,
loop: true
});
new Swiper('.promotion .swiper-container', {
slidesPerView: 3, //한번에 보여줄 슬라이드 개수
spaceBetween: 10, //슬라이드 사이 여백
centeredSlides: true, //1번 슬라이드가 가운데 보이기
loop: true,
// autoplay: {
// delay: 5000 //기본값:3000(3초)
// },
pagination: {
el: '.promotion .swiper-pagination', //페이지 번호 요소 선택자
clickable: true //사용자의 페이지 번호 요소 제어 가능 여부
},
navigation: {
prevEl: '.promotion .swiper-prev',
nextEl: '.promotion .swiper-next'
}
});