요소의 앞뒤를 디자인 하는 가상클래스 before, after을 이용하여 SNS 아이콘 애니메이션 네이게이션 만들기
<div class="gnb">
<a href="javascript:viod(0)" data-text="CodingWorks Online Class"></a>
</div>
/* Google Web Font */
@import url('https://fonts.googleapis.com/css?family=Raleway&display=swap');
/* Fontawesome 4.7 */
@import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
body {
font-family: 'Raleway', sans-serif;
line-height: 1.5em;
margin: 0;
font-weight: 300;
color: #222;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
a {
text-decoration: none;
color: #222;
}
.gnb a {
width: 300px;
display: block;
height: 40px;
position: relative;
overflow: hidden;
}
.gnb a::before,
.gnb a::after {
content: attr(data-text);
position: absolute;
width: inherit;
height: inherit;
text-align: center;
line-height: 40px;
color: #fff;
text-transform: uppercase;
transition: 0.3s;
}
.gnb a::before {
background-color: crimson;
top: 0;
}
.gnb a::after {
background-color: royalblue;
top: 40px;
}
.gnb a:hover::before {
top: -40px;
}
.gnb a:hover::after {
top: 0;
}