Skip to content

Instantly share code, notes, and snippets.

@frankhn
Created March 17, 2020 10:06
Show Gist options
  • Save frankhn/5075600ba9558e5b1da96e30bdf4bd4b to your computer and use it in GitHub Desktop.
Save frankhn/5075600ba9558e5b1da96e30bdf4bd4b to your computer and use it in GitHub Desktop.
pagination hover animation
<nav><span class="text">NEXT</span>
<div class="left">
<a href="" class="prev"></a>
<a href="">1</a>
<!-- <a href="">2</a>
<a href="">3</a> -->
<span class="line"></span>
</div>
<div class="right">
<a href="" class="next"></a>
<a href="">2</a>
<a href="">3</a>
<!-- <a href="">5</a>
<a href="">6</a> -->
<span class="line"></span>
</div>
</nav>
body {
margin: 0;
background: #F6B533;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
}
a {
text-decoration: none;
outline: none;
display: block;
padding: 20px 0;
width: 40px;
text-align: center;
color: white;
float: left;
}
div {
position: absolute;
top: 0;
opacity: 0;
width: 40px;
overflow: hidden;
transition: .5s linear;
}
.left {
left: 0;
}
.right {
right: 0;
}
.line {
width: 30px;
height: 2px;
position: absolute;
bottom: 10px;
left: -35px;
background: white;
transition: .5s linear .2s;
}
.left a:nth-child(2):hover ~ .line,
.right a:nth-child(2):hover ~ .line {
left: 5px;
}
.left a:nth-child(3):hover ~ .line,
.right a:nth-child(3):hover ~ .line {
left: 45px;
}
.left a:nth-child(4):hover ~ .line,
.right a:nth-child(4):hover ~ .line {
left: 85px;
}
nav {
background: #FCFCFC;
color: #4D4644;
position: relative;
border-radius: 6px;
overflow: hidden;
width: 15rem;
text-align: center;
box-shadow: 0 0 20px rgba(0,0,0,.2);
transition: .3s linear;
}
.text {
display: inline-block;
letter-spacing: 2px;
padding: 20px 10px;
cursor: pointer;
}
nav:hover div {
background: #D8CDC9;
opacity: 1;
}
div:hover .prev {
opacity: 0;
display: none;
}
div:hover .next {
display: none;
}
div:hover {
width: auto;
}
.prev:before {
content: "\f104";
font-family: FontAwesome;
}
.next:before {
content: "\f105";
font-family: FontAwesome;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment