сделал адаптивность для how

fitness
Kirill Pet 8 months ago
parent b155852f9c
commit 352e1ead99
  1. 9
      assets/css/gp-style-desktop.css
  2. 50
      assets/css/gp-style-tablet.css
  3. 54
      assets/js/main.js
  4. 10
      index.html

@ -557,6 +557,15 @@
width: 336px; width: 336px;
height: 336px; height: 336px;
} }
@media only screen and (min-width: 992px) and (max-width: 1481px) {
.how-content-item__img{
display: none;
}
.how-content-item__text{
width: 100%;
}
}
/* how */ /* how */
/* free */ /* free */

@ -404,4 +404,52 @@ main{
background-repeat: no-repeat; background-repeat: no-repeat;
} }
} }
/* projects */ /* projects */
/* how */
@media only screen and (max-width: 992px) {
.how{
margin-top: 40px;
}
.how__content{
display: none;
}
.how__control{
width: 100%;
}
.how-control__item{
flex-direction: column;
align-items: start;
}
.how-control-item__number{
width: 40px;
font-size: 20px;
}
.how-control__item__name{
margin-top: 16px;
margin-left: 0;
max-width: 100%;
font-size: 20px;
}
.how-content__item-block{
position: static;
}
.how-content__item-block.active{
margin-top: 16px;
}
.how-content__item{
padding: 16px;
}
.how-content-item__text{
width: 100%;
}
.how-content-item__img{
display: none;
}
}
/* how */
@media only screen and (max-width: 992px) {}

@ -13,8 +13,6 @@ const gymSwiper = new Swiper('.gym-swiper', {
} }
}); });
const reviewsSwiper = new Swiper('.reviews-swiper', { const reviewsSwiper = new Swiper('.reviews-swiper', {
spaceBetween: 24, spaceBetween: 24,
// If we need pagination // If we need pagination
@ -42,7 +40,6 @@ const reviewsSwiper = new Swiper('.reviews-swiper', {
} }
}) })
const projectsSwiper = new Swiper('.projects-swiper', { const projectsSwiper = new Swiper('.projects-swiper', {
direction: 'horizontal', direction: 'horizontal',
breakpoints: { breakpoints: {
@ -79,27 +76,43 @@ itemButtons.forEach((button) => {
button.onclick = function name(params, index) { button.onclick = function name(params, index) {
let activeContent = document.querySelector('.how__content').querySelector('.active'), let activeContent = document.querySelector('.how-content__item-block.active'),
activeButton = document.querySelector('.how__control').querySelector('.active'); activeButton = document.querySelector('.how-control__item.active');
if (activeContent.dataset.num == button.dataset.num) return; if (activeContent.dataset.num == button.dataset.num) return;
activeContent.style.height = '0px'; activeContent.style.height = `${activeContent.offsetHeight}px`;
activeContent.classList.remove('active');
activeButton.classList.remove('active');
let newActive = document.querySelector(`.how-content__item-block[data-num='${num}']`),
newButton = document.querySelector(`.how-control__item[data-num='${num}']`);
setTimeout(() => { setTimeout(() => {
let newHeight = newActive.querySelector('.how-content__item').offsetHeight + 'px'; activeContent.style.height = '0px';
newActive.style.height = newHeight; activeContent.classList.remove('active');
newActive.classList.add('active'); activeButton.classList.remove('active');
newButton.classList.add('active');
}, 300); let newActive = document.querySelector(`.how-content__item-block[data-num='${num}']`),
newButton = document.querySelector(`.how-control__item[data-num='${num}']`);
setTimeout(() => {
let newHeight = newActive.querySelector('.how-content__item').offsetHeight + 'px';
newActive.style.height = newHeight;
newActive.classList.add('active');
newButton.classList.add('active');
setTimeout(() => {
newActive.style.height = 'auto';
}, 300);
}, 300);
}, 0);
} }
}) })
let screenWidth = window.screen.width;
if (screenWidth <= 992) {
howPhone();
}else{
howPc();
}
function howPc() { function howPc() {
if (document.querySelector('.how__content').querySelector('.how-content__item-block')) { if (document.querySelector('.how__content').querySelector('.how-content__item-block')) {
return; return;
@ -113,7 +126,8 @@ function howPc() {
}); });
} }
function howPhone() { function howPhone() {
if (!document.querySelector('.how__content').querySelector('.how-content__item-block')) {
if (!document.querySelector('.how__content').querySelector('.how-content__item-block')) {
return; return;
} }
@ -126,7 +140,7 @@ function howPhone() {
button.after(block); button.after(block);
}); });
} }
// how end
// resize // resize
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
@ -137,4 +151,4 @@ window.addEventListener('resize', () => {
}else{ }else{
howPc(); howPc();
} }
}); });

@ -299,7 +299,7 @@
</article> </article>
</div> --> </div> -->
<div class="main__item"> <!-- <div class="main__item">
<p class="title-1"> <p class="title-1">
Разработанные проекты Разработанные проекты
</p> </p>
@ -429,9 +429,9 @@
все проекты все проекты
</a> </a>
</div> </div>
</div> </div> -->
<!-- <div class="main__item"> <div class="main__item">
<p class="title-1"> <p class="title-1">
Как мы это делаем? Не так просто, как кажется! Как мы это делаем? Не так просто, как кажется!
</p> </p>
@ -470,7 +470,7 @@
</div> </div>
<div class="how__content"> <div class="how__content">
<div class="how-content__item-block active" style="height: 354px;" data-num="1"> <div class="how-content__item-block active" data-num="1" style="height: auto;">
<div class="how-content__item"> <div class="how-content__item">
<p class="text-1"> <p class="text-1">
Проводим экспертизу помещения и определяем рыночный сегмент проекта Проводим экспертизу помещения и определяем рыночный сегмент проекта
@ -549,7 +549,7 @@
</div> </div>
</div> </div>
</article> </article>
</div> --> </div>
<!-- <div class="main__item"> <!-- <div class="main__item">
<article class="free"> <article class="free">

Loading…
Cancel
Save