swiper 가로세로 배열 질문입니다...
본문
가로 4개 세로 3개로 구성된 슬라이드 인데요
1 2 3 4
5 6 7 8
9 10 11 12
첫슬라이드에 이런 순서로 나타난뒤 다음페이지도
13 14 15 16
17 18 19 20
21 22 23 24
같은 순서로 나오게 하고싶은데
[슬라이드1] > [슬라이드2]
1 4 7 10 > 13 16 19 22
2 5 8 11 > 14 17 20 23
3 6 9 12 > 15 18 21 24
기본값은 이렇게 나오고
[슬라이드1] > [슬라이드2]
1 2 3 4 > 5 6 7 8
9 10 11 12 > 13 14 15 16
17 18 19 20 > 21 22 23 24
slidesPerColumnFill: 'row' 를 넣으면
이런식으로 두번째 페이지에 5 6 7 8 순서의 이미지가 나옵니다ㅜㅜ
원하는대로 출력하려면 어떻게 해야되나여..
고수님들 도와주세욤!!
답변 2
단일 스와이퍼로는 안되고 nest로 구현해봤습니다. 게시판등에서 불러올경우 12개씩 끊어서 .swiper-parent .swiper-slide안에 넣어주시면 되겠네요.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Swiper demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<!-- Link Swiper's CSS -->
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css"/>
<!-- Demo styles -->
<style>
html,
body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.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-child .swiper-slide{
height: 100px;
}
</style>
</head>
<body>
<!-- Swiper -->
<div class="swiper-container swiper-parent">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-container swiper-child">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
<div class="swiper-slide">Slide 11</div>
<div class="swiper-slide">Slide 12</div>
</div>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-container swiper-child">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 13</div>
<div class="swiper-slide">Slide 14</div>
<div class="swiper-slide">Slide 15</div>
<div class="swiper-slide">Slide 16</div>
<div class="swiper-slide">Slide 17</div>
<div class="swiper-slide">Slide 18</div>
<div class="swiper-slide">Slide 19</div>
<div class="swiper-slide">Slide 20</div>
<div class="swiper-slide">Slide 21</div>
<div class="swiper-slide">Slide 22</div>
<div class="swiper-slide">Slide 23</div>
<div class="swiper-slide">Slide 24</div>
</div>
</div>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<div class="swiper-pagination"></div>
</div>
<!-- Swiper JS -->
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<!-- Initialize Swiper -->
<script>
var swiper_parent = new Swiper('.swiper-parent', {
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
},
pagination: {
el: '.swiper-pagination',
type: 'bullets',
clickable: true
}
});
var swiper_child = new Swiper('.swiper-child', {
nested: true,
slidesPerColumnFill: 'row',
slidesPerView: 4,
slidesPerColumn: 3,
slidesPerGroup: 12
});
</script>
</body>
</html>
!-->
swiper에는 자체적으로 지원하는게 없는것 같네요
flex-order 등을 활용하여 하셔야 할 것 같습니다.
답변을 작성하시기 전에 로그인 해주세요.