サンプルの「Hover Me」ボタンをhoverすると、cssアニメーションで4つのソーシャルリンクを表示するnaviに変化します。
サンプル
サンプルのhtmlソース
<div class="hover">
<span>Hover Me</span>
<a class="social-link" href="https://twitter.com/" target="_blank">
<i class="fab fa-twitter"></i></a>
<a class="social-link" href="https://codepen.io/" target="_blank">
<i class="fab fa-codepen"></i></a>
<a class="social-link" href="https://www.instagram.com/" target="_blank">
<i class="fab fa-instagram"></i></a>
<a class="social-link" href="https://github.com/" target="_blank">
<i class="fab fa-github"></i></a>
</div>
サンプルのCSSソース
.hover {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 300px;
height: 75px;
background-color: #4DB6AC;
border-radius: 99px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
overflow: hidden;
}
.hover:before, .hover:after {
position: absolute;
top: 0;
display: flex;
align-items: center;
width: 50%;
height: 100%;
transition: 0.25s linear;
z-index: 1;
}
.hover:before {
content: '';
left: 0;
justify-content: flex-end;
background-color: #4DB6AC;
}
.hover:after {
content: '';
right: 0;
justify-content: flex-start;
background-color: #44a69c;
}
.hover:hover {
background-color: #46627f;
box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}
.hover:hover span {
opacity: 0;
z-index: -3;
}
.hover:hover:before {
opacity: 0.5;
transform: translateY(-100%);
}
.hover:hover:after {
opacity: 0.5;
transform: translateY(100%);
}
.hover span {
position: absolute;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
color: whitesmoke;
font-family: 'Fira Mono', monospace;
font-size: 24px;
font-weight: 700;
opacity: 1;
transition: opacity 0.25s;
z-index: 2;
}
.hover .social-link {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 25%;
height: 100%;
color: whitesmoke;
font-size: 24px;
text-decoration: none;
transition: 0.25s;
}
.hover .social-link i {
text-shadow: 1px 1px rgba(70, 98, 127, 0.7);
transform: scale(1);
}
.hover .social-link:hover {
background-color: rgba(245, 245, 245, 0.1);
color:#8fe;
}
.hover .social-link:hover i {
animation: bounce 0.4s linear;
}
@keyframes bounce {
40% {
transform: scale(1.4);
}
60% {
transform: scale(0.8);
}
80% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}