我使用的是swiper slider,並且希望在滑塊外部具有導航箭頭。我基本上想要做的就像它在airbnb網站上的樣子一樣,其中帶圖像的滑塊佔據了整個12列的行,但箭頭在它之外。 我使用引導嘰嘰喳喳css框架,我已經嘗試過各種東西,但沒有工作,不知道如何實現這一目標?CSS - 如何使滑塊外部的滑動條滑塊佔用12列行
的CSS是這樣的:
.swiper-container {
margin-top: 50px;
position: relative;
}
.arrow-left {
position: absolute;
top: 50%;
left: 0;
}
.arrow-right {
position: absolute;
top: 50%;
right: 0;
}
HTML如下:
<div class="row swiper-container">
<div class="arrow-left">
<i class="ion-chevron-left"></i>
</div>
<div class="col-md-12 swiper-wrapper">
@foreach($videos as $video)
<div class="swiper-slide video-card">
<header class="card__thumb">
<a href="/player/{{ $player->id }}/video/{{ $video->id }}"><img src="{{ $video->getThumbnail() }}"/></a>
</header>
<div class="card__body">
<div class="card__category">
</div>
<small>
{{ $video->created_at->diffForHumans() }}
</small>
<span class="video-title">
<p>
@if($video->title != '')
{{ $video->title }} <i class="ion-arrow-right-c"></i>
@else
Untitled
@endif
</p>
</span>
</div>
</div>
@endforeach
</div>
<div class="arrow-right">
<i class="ion-chevron-right"></i>
</div>
</div>
這是腳本:
var carousel = function carousel() {
var mySwiper = new Swiper ('.swiper-container', {
direction: 'horizontal',
nextButton: '.arrow-left',
prevButton: '.arrow-right',
slidesPerView: 4,
simulateTouch: false,
spaceBetween: 15,
breakpoints: {
1181: {
slidesPerView: 4
},
1180: {
slidesPerView: 3
},
1020: {
slidesPerView: 2
},
700: {
slidesPerView: 1
}
}
});
};
$(document).ready(function() {
carousel();
});
很好的JS是打破它爲我的演示,但基本上你想要做的是使用位置:絕對,然後使用正確的:(然而男人y像素你想)和左:(無論你想要多像素) – Keith
是的,我這樣做,但這是行不通的,因爲箭頭沒有定位像他們應該然後 – Leff
沒有swiper滑塊在線文件,我不能複製此 – Keith