Back
Learn how to create an engaging avatar that reacts to user interaction, enhancing profile visibility and user engagement.
<div class="avatar-container"> <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="User Avatar" class="avatar"> <div class="overlay"> <div class="text">View Profile</div> </div> </div>
.avatar-container { position: relative; display: inline-block; }
.avatar { border-radius: 50%; transition: transform 0.3s ease; width: 100px; height: 100px; cursor: pointer; } .avatar:hover { transform: scale(1.1); }
.overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); border-radius: 50%; opacity: 0; transition: opacity 0.3s ease; display: flex; justify-content: center; align-items: center; } .avatar-container:hover .overlay { opacity: 1; }
.text { color: white; font-size: 14px; text-align: center; }
<div class="avatar-container"> <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="User Avatar" class="avatar"> <div class="overlay"> <div class="text">View Profile</div> </div> </div> <style> .avatar-container { position: relative; display: inline-block; } .avatar { border-radius: 50%; transition: transform 0.3s ease; width: 100px; height: 100px; cursor: pointer; } .avatar:hover { transform: scale(1.1); } .overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); border-radius: 50%; opacity: 0; transition: opacity 0.3s ease; display: flex; justify-content: center; align-items: center; } .avatar-container:hover .overlay { opacity: 1; } .text { color: white; font-size: 14px; text-align: center; } </style>Thank you for reading this article.
Comments