Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2015 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/b9ae0c008423396048c5 to your computer and use it in GitHub Desktop.
Save anonymous/b9ae0c008423396048c5 to your computer and use it in GitHub Desktop.
Boxed in Link Hovers
<ul>
<li>
<a href="#" data-text="Works">Works</a>
</li>
<li>
<a href="#" data-text="About Me">About Me</a>
</li>
<li>
<a href="#" data-text="Resume">Resume</a>
</li>
<li>
<a href="#" data-text="Contact">Contact</a>
</li>
</ul>
body {
margin: 0;
font-family: Helvetica, Arial, sans-serif;
background-color: rgb(213,30,56);
font-size: 1.5em;
}
ul {
display: table;
white-space: nowrap;
}
li {
display: table-cell;
vertical-align: middle;
padding: 0 10px;
position: relative;
}
a {
text-decoration: none;
color: rgba(255,255,255,1);
position: relative;
padding: 16px 7px;
border-top: 2px solid rgba(255,255,255,0);
border-bottom: 2px solid rgba(255,255,255,0);
transition: padding .3s,border-color .3s;
}
a:focus, a:hover {
padding: 5px 7px;
border-color: rgba(255,255,255,1);
}
a::before {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
max-height: 0;
color: rgba(255,255,255,0);
border-left: 2px solid rgba(255,255,255,0);
content: attr(data-text);
transition: max-height .3s,border-color 0s;
}
a::after {
position: absolute;
left: 0;
bottom: 0;
right: 0;
padding: 5px;
max-height: 0;
color: rgba(255,255,255,0);
border-right: 2px solid rgba(255,255,255,0);
content: attr(data-text);
transition: max-height .3s,border-color 0s;
}
a:focus::before, a:hover::before, a:focus::after, a:hover::after {
max-height: 100%;
transition-delay: .28s;
border-color: rgba(255,255,255,1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment