CSS Buttons With Arrows and Animation

In the previous example, we saw CSS Buttons with Arrows, in this one we go a step further and add animation to the buttons with arrows in all directions.

HTML Snippet


<div class="button-container">
    <button class="arrow-button up-arrow">
        <span class="arrow"></span>
    </button>
    <button class="arrow-button right-arrow">
        <span class="arrow"></span>
    </button>
    <button class="arrow-button down-arrow">
        <span class="arrow"></span>
    </button>
    <button class="arrow-button left-arrow">
        <span class="arrow"></span>
    </button>
</div>
    

CSS Snippet


.button-container {
    display: flex;
    gap: 10px;
}

.arrow-button {
    width: 60px;
    height: 60px;
    background-color: #ccc;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s, transform 0.3s;
    overflow: hidden;
}

.arrow-button:hover {
    background-color: #2196F3;
    transform: scale(1.1);
}

.arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #fff;
    transition: transform 0.3s;
}

.arrow-button:hover .arrow {
    animation: arrowAnimation 0.5s ease-in-out;
}

@keyframes arrowAnimation {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); }
}
    

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!