JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>
.feedwrap {
position: relative;
height: 850px;
width: 400px;
overflow: hidden;
}
.feedwrap__container {
position: absolute;
top: 0;
height: 100%;
overflow-y: hidden;
}
.feedwrap .feedback__item {
margin-bottom: 48px;
}
</style>
<div class="feedwrap__ctrls">
<a href="#" class="feedwrap__prev">НАЗАД</a>
<a href="#" class="feedwrap__next">ВПЕРЕД</a>
</div>
<div class="feedwrap">
<div class="feedwrap__container">
<div class="feedback__item slide" data-count="1">
<div class="feedback__item-header">
<div>
<div class="feedback__item-name">Сергей Игнатьев 33</div>
</div>
<div class="feedback__item-rating">
<img src="http://test.insite.vip/assets/templates/villplast/img/star.svg" class="feedback__item-rating-star" alt="">
<img src="http://test.insite.vip/assets/templates/villplast/img/star.svg" class="feedback__item-rating-star" alt="">
<img src="http://test.insite.vip/assets/templates/villplast/img/star.svg" class="feedback__item-rating-star" alt="">
<img src="http://test.insite.vip/assets/templates/villplast/img/star.svg" class="feedback__item-rating-star" alt="">
<img src="http://test.insite.vip/assets/templates/villplast/img/star.svg" class="feedback__item-rating-star" alt="">
</div>
</div>
<div class="feedback__item-text">Долго выбирали подоконник, рассматривали несколько компаний, мониторили цены, которые прямо скажем расстраивали. Приехали в ВИЛ ПЛАСТ за откосами, увидели их новые подоконники и ахнули, "глаза разбежались"…. Цена и качество, всё совпало. Купили подоконник ТМ VILPLAST, цвет Золотой дуб, очень довольны! Спасибо, будем рекомендовать!</div>
</div>
<div class="feedback__item slide" data-count="2">
<div class="feedback__item-header">
<div>
<div...
CSS
.feedback__item {
padding: 33px 29px;
background: #FFFFFF;
border-radius: 24px;
box-shadow: 0px 10px 80px rgba(93, 58, 76, 0.1);
}
@media (min-width: 1140px) {
.feedback__item {
padding: 56px 64px;
}
}
.feedback__item-header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-bottom: 24px;
padding-bottom: 24px;
border-bottom: 1px solid #E85939;
}
.swiper-slide-prev .feedback__item-header {
border: none;
}
.feedback__item-name {
font-family: Montserrat;
margin-bottom: 4px;
font-weight: bold;
font-size: 18px;
line-height: 22px;
color: #E85939;
}
.feedback__item-company-name {
font-family: Montserrat;
margin-bottom: 10px;
font-size: 14px;
line-height: 17px;
color: #242424;
}
.feedback__item-rating {
display: flex;
}
.feedback__item-rating-star {
width: 24px !important;
margin-right: 8px;
flex: none;
}
.feedback__item-text {
font-family: Montserrat;
font-size: 14px;
line-height: 20px;
color: #242424;
}
@media (min-width: 992px) {
.feedback__item-text {
font-size: 18px;
line-height: 26px;
}
}
JavaScript
$(window).on("load", function() {
var container = $(".feedwrap__container"), hh = $(".feedwrap").height();
function nextSlide(e) {
e.preventDefault();
var slide = $(".slide:first", container), height = slide.outerHeight(true),
active = $(".slide", container).eq(2), height_active = container.scrollTop() + active.position().top - (hh - active.outerHeight(true))/2 - 48;
container.stop().animate({scrollTop: height_active}, function() {
container.append(slide);
container.scrollTop(height_active - height);
});
}
$(".feedwrap__next").on("click", nextSlide).click();
function prevSlide(e) {
e.preventDefault();
var slide = $(".slide:last", container), height = slide.outerHeight(true);
container.prepend(slide);
container.scrollTop(container.scrollTop() + height);
var active = $(".slide", container).eq(1), height_active = container.scrollTop() + active.position().top - (hh - active.outerHeight(true))/2 - 48;
container.stop().animate({scrollTop:height_active});
}
$(".feedwrap__prev").on("click", prevSlide);
});