сделал how js для пк

This commit is contained in:
Kirill Pet
2024-12-18 23:25:47 +03:00
parent 8ec1dd88d6
commit 96948651b2
3 changed files with 114 additions and 78 deletions

View File

@@ -490,6 +490,12 @@
width: 100%;
}
.how-content__item-block{
height: 0;
overflow: hidden;
transition: height .3s;
}
.how-content__item{
width: 100%;
@@ -498,11 +504,6 @@
background-color: var(--background-grey);
overflow: hidden;
display: none;
}
.how-content__item.active{
display: block;
}
.how-content__item .text-2{
margin-top: 16px;

View File

@@ -43,3 +43,32 @@ const reviewsSwiper = new Swiper('.reviews-swiper', {
})
// gymSwiper.destroy();
// how
function howPc() {
let itemButtons = document.querySelectorAll('.how-control__item'),
itemBlocks = document.querySelectorAll('.how-content__item-block');
itemButtons.forEach((button, index) => {
let block = itemBlocks[index];
button.onclick = function () {
let activeContent = document.querySelector('.how__content').querySelector('.active'),
activeButton = document.querySelector('.how__control').querySelector('.active');
activeContent.style.height = '0px';
activeContent.classList.remove('active');
activeButton.classList.remove('active');
setTimeout(() => {
let newHeight = block.querySelector('.how-content__item').offsetHeight + 'px';
block.style.height = newHeight;
block.classList.add('active');
button.classList.add('active');
}, 300);
}
})
}
howPc();