@saver116
front-end developer

Как задать transition к button?

надо чтобы при исчезновении button был transition на 0,3 секунд
<div class="item4">
                <div class="button1">
                    <div class="icon"><i class="fab fa-steam-symbol"></i></div>
                    <span>Steam</span>
                </div>
            </div>
            <div class="item4">
                <div class="button">
                    <div class="icon"><i class="fab fa-google"></i></div>
                    <span>Google</span>
                </div>
            </div>

.item4 .button {
    display: inline-block;
    width: 40px;
    height: 38px;
    margin: 15px 5px;
    overflow: hidden;
    background: #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease-out;
}

.item4 .button:hover {
    width: 120px;
}

.item4 .button .icon {
    display: inline-block;
    height: 20px;
    width: 20px;
    text-align: center;
    border-radius: 50px;
    box-sizing: border-box;
    line-height: 45px;
}

.item4 .button .icon i {
    font-size: 24px;
    line-height: 20px;
    padding-left: 8px;
}

.item4 .button span {
    font-size: 24px;
    font-weight: 50px;
    line-height: 40px;
    margin-left: 15px;
}

.item4 .button1 {
    display: inline-block;
    width: 40px;
    height: 38px;
    margin: 15px 5px;
    overflow: hidden;
    background: #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease-out;
}

.item4 .button1:hover {
    width: 120px;
}

.item4 .button1:hover>.button {
    visibility: hidden;
}

.item4 .button1 .icon {
    display: inline-block;
    height: 20px;
    width: 20px;
    text-align: center;
    border-radius: 50px;
    box-sizing: border-box;
    line-height: 45px;
}

.item4 .button1 .icon i {
    font-size: 24px;
    line-height: 20px;
    padding-left: 10px;
}

.item4 .button1 span {
    font-size: 24px;
    font-weight: 50px;
    line-height: 40px;
    margin-left: 15px;
}

.active {
    visibility: hidden;
}

const buttonOne = document.querySelector(".button1");
const buttonTwo = document.querySelector(".button");

const bttnClassAdd = () => {
    buttonTwo.classList.add("active");
};

const bttnClassRemove = () => {
    buttonTwo.classList.remove("active");
};

buttonOne.addEventListener("mouseover", bttnClassAdd);
buttonOne.addEventListener("mouseout", bttnClassRemove);
  • Вопрос задан
  • 137 просмотров
Решения вопроса 1
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
SummerWeb Ярославль
от 120 000 до 180 000 ₽
Brightdata Тель-Авив
от 5 500 до 6 500 $
Market-place Ростов-на-Дону
от 100 000 до 200 000 ₽
24 июн. 2024, в 14:45
2500 руб./за проект
24 июн. 2024, в 14:39
2000 руб./в час
24 июн. 2024, в 14:07
2000 руб./за проект