Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.