Vissza az animációkhoz
Gombanimációk

Mágneses gomb

Élő előnézet – az animáció teljes méretben.

Élő előnézet
HTML · CSS · JS
HTML
<button class="we-btn-magnetic" type="button">
    <span class="we-btn-magnetic-text">Megnézem</span>
    <span class="we-btn-magnetic-arrow">→</span>
</button>
CSS
.we-btn-magnetic {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 16px;

    min-width: 175px;
    height: 54px;

    padding: 0 26px;

    border: 1px solid rgba(142,232,212,.28);
    border-radius: 12px;

    background: #10191c;
    color: #f2f4f0;

    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .4px;

    cursor: pointer;

    transition:
        transform .45s cubic-bezier(.22,1,.36,1),
        border-radius .45s ease,
        border-color .4s ease,
        box-shadow .45s ease;
}

.we-btn-magnetic::before {
    content: "";

    position: absolute;
    inset: 0;

    border-radius: inherit;

    background: #8ee8d4;

    transform: scale(.82);
    opacity: 0;

    transition:
        transform .45s cubic-bezier(.22,1,.36,1),
        opacity .35s ease;
}

.we-btn-magnetic-text,
.we-btn-magnetic-arrow {
    position: relative;
    z-index: 2;

    transition:
        transform .45s cubic-bezier(.22,1,.36,1),
        color .35s ease;
}

.we-btn-magnetic-arrow {
    font-size: 20px;
    line-height: 1;
}

.we-btn-magnetic:hover {
    transform:
        translateY(-4px)
        scale(1.03);

    border-radius: 17px;
    border-color: #8ee8d4;

    box-shadow:
        0 20px 40px rgba(0,0,0,.38);
}

.we-btn-magnetic:hover::before {
    transform: scale(1);
    opacity: 1;
}

.we-btn-magnetic:hover .we-btn-magnetic-text {
    color: #081012;

    transform:
        translateX(-3px);
}

.we-btn-magnetic:hover .we-btn-magnetic-arrow {
    color: #081012;

    transform:
        translateX(7px)
        scale(1.15);
}

.we-btn-magnetic:active {
    transform:
        translateY(-1px)
        scale(.97);
}
JavaScript
Ehhez az animációhoz nincs külön JavaScript.