Не работает свойство transform: scale()

Рейтинг: 0Ответов: 1Опубликовано: 23.06.2023

Есть следующий html и css код:

<article class="why-us">
    <div class="why-us__head">
        <div class="why-us__title">WHY CHOOSE US <br>FOR <span>YOUR HEALTHY FOOD</span></div>
        <div class="why-us__description">We continue to consistently choose and maintain
            the quality of the fruit served, so that it remains fresh and nutritious when you eat it.
        </div>
    </div>

    <div class="cards">
        <div class="cards__item cards__item1">
            <div class="cards__logo">
                <img src="images/cards-icon1.png" alt="">
            </div>
            <div class="cards__description">
                <div class="cards__title">Own fruit orchard</div>
                <div class="cards__text">Langsung dari Kebun Sendiri yang
                    tersebar di setiap provinsi yang
                    memiliki cabang toko Jez Salad.
                </div>
            </div>
            <div class="cards-button">
                <div class="cards-button__text">Learn more</div>
            </div>
        </div>

        <div class="cards__item cards__item2">
            <div class="cards__logo">
                <img src="images/cards-icon2.png" alt="">
            </div>
            <div class="cards__description">
                <div class="cards__title">#1 Healthy Fruit Salad</div>
                <div class="cards__text">The pioneer of healthy fruit salads that
                    are delicious & suitable for all people
                    with the best quality assurance.
                </div>
            </div>
            <div class="cards-button">
                <div class="cards-button__text">Learn more</div>
            </div>
        </div>

        <div class="cards__item cards__item3">
            <div class="cards__logo">
                <img src="images/cards-icon3.png" alt="">
            </div>
            <div class="cards__description">
                <div class="cards__title">100 Top Brand</div>
                <div class="cards__text">We are one of the best brands in the
                    Food and Beverage sector in Indonesia.
                </div>
            </div>
            <div class="cards-button">
                <div class="cards-button__text">Learn more</div>
            </div>
        </div>
    </div>
</article>

<script>
    let mas = ['.cards__item1', '.cards__item2', '.cards__item3'];
    let mas2 = ['item1', 'item2', 'item3'];
    for (let i = 0; i < 3; i++)
    {
        const observer = new IntersectionObserver(entries => {
            // перебор записей
            entries.forEach(entry => {
                // если элемент появился
                if (entry.isIntersecting) {
                    // добавить ему CSS-класс
                    entry.target.classList.add(mas2[i]);
                }
            });
        });
        observer.observe(document.querySelector(mas[i]));
    }
</script>
.why-us {
    max-width: 1170px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0);
    padding: 100px 0;
}

.why-us__head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 64px;
}

.why-us__title {
    width: 586px;
    color: #585858;
    font-size: 48px;
    font-family: Poppins-SemiBold, sans-serif;
    letter-spacing: -2px;
    line-height: 140%;
}
.why-us__title span {
    color: #FB9333;
}

.why-us__description {
    font-family: Poppins-Medium, sans-serif;
    width: 470px;
    font-size: 20px;
    line-height: 180%;
    color: #828282;
}

.cards {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

@keyframes show-items {
    0% {
        opacity: 0;
        transform: translateY(200px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        transition: 2s;
    }
}

.cards__item {
    opacity: 0;
    width: 31%;
    height: 467px;
    border: #FB9333 1px solid;
    border-radius: 50px;
    padding: 30px;
    box-sizing: border-box;
    background: #ffffff;
}

.cards__item:hover {
    -webkit-box-shadow: 4px 4px 41px 21px rgba(232, 217, 195, 0.39);
    -moz-box-shadow: 4px 4px 41px 21px rgba(232, 217, 195, 0.39);
    box-shadow: 4px 4px 41px 21px rgba(232, 217, 195, 0.39);
    transform: scale(105%);
    transition: .3s;
}
.cards-button:hover  {
    color: white;
    background: url("../images/Arrow-Right-White.svg") no-repeat right, #FB9333;
    background-position-x: 110px;
}


.item1 {
    opacity: 0;
    transition: ease-in-out;
    animation: show-items 1s;
    animation-fill-mode: forwards;
    animation-delay: .5s;
}

.item2 {
    opacity: 0;
    transition: ease-in-out .5s;
    animation: show-items 1s;
    animation-fill-mode: forwards;
    animation-delay: 1s;
}

.item3 {
    opacity: 0;
    transition: ease-in-out .5s;
    animation: show-items 1s;
    animation-fill-mode: forwards;
    animation-delay: 1.5s;
}

.cards__logo {
    width: 122px;
    margin-bottom: 70px;
}

.cards__logo img {
    width: 100%;
}

.cards__title {
    font-family: Poppins-SemiBold, sans-serif;
    color: #2B2B2B;
    font-size: 24px;
}

.cards__text {
    color: #575757;
    font-size: 16px;
    font-family: Poppins-Regular, sans-serif;
    line-height: 180%;
    letter-spacing: -0.32px;
}

.cards-button {
    position: absolute;
    margin-top: 24px;
    display: flex;
    padding: 10px 36px 10px 24px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    border-radius: 50px;
    color: #575757;
    background: url("../images/Arrow-Right-Gray.svg") no-repeat right;
    background-position-x: 110px;
    transition: .3s;
}

Почему со скриптом не хочет работать transform: scale() в .cards__item:hover? Как только я комментирую скрипт - scale работает

Ответы

▲ 0

потому-что уже прописан в анимации transform и еще дня класса который добавляется через js примерно это выглядит вот так

transform: translateY(0);
transform: scale(105%);

а надо что бы было

transform: translateY(0) scale(105%);

можно либо все анимации сделать в js ну или в @keyframes прописать top вместо transform: translateY();