I'm attempting to implement a sliding horizontal line that moves on click of hyperlinks. Check out the code at: http://codepen.io/anon/pen/JdEPPb
The HTML structure is as follows:
* {
box-sizing: border-box;
}
body {
font: 300 100% 'Helvetica Neue', Helvetica, Arial;
}
.container {
width: 50%;
margin: 0 auto;
}
ul li {
display: inline;
text-align: center;
}
a {
display: inline-block;
width: 25%;
padding: .75rem 0;
text-decoration: none;
color: #333;
}
.one:active ~ hr {
margin-left: 0%;
}
.two:active ~ hr {
margin-left: 25%;
}
.three:active ~ hr {
margin-left: 50%;
}
.four:active ~ hr {
margin-left: 75%;
}
hr {
height: .25rem;
width: 25%;
margin: 0;
background: tomato;
border: none;
transition: 0.3s ease-in-out;
}
<div class="container">
<ul>
<li class="one"><a href="#">Uno</a></li><!--
--><li class="two"><a href="#">Dos</a></li><!--
--><li class="three"><a href="#">Tres</a></li><!--
--><li class="four"><a href="#">Quatro</a></li>
<hr />
</ul>
</div>
No JavaScript code is used in this implementation.
Currently, when I click on Two, the underline doesn't move underneath it immediately. I have to hold the click for longer for it to move, and when I release the mouse button, it falls back to One.