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); }
}
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!