I've already known this underline/border-bottom animation for a long time (fiddle: https://jsfiddle.net/0ou3o9rn/4/), but I can't seem to find out how I'd have to style my codes correctly... Nothing works.
CSS:
.lists li {
position: absolute;
display:block;
left: 0;
top:90%;
margin:0 auto;
height: 2px;
background-color: #000;
width: 0%;
transition: width 1s;}
HTML:
<div class="lists"><ul>
<li><a href="/">link 1</a></li>
<li><a href="/">link 2</a></li>
<li><a href="/">link 3</a></li>
</ul></div>
This for example doesn't work, but I still want an animated underline to appear when I hover over the li
s/a
s. Can anyone help me? Thank you!
Slider is a box with 2px height. Initially widht of block is 0px. When user hovers over the #name, then width of slider becomes 100%. Now css transition is applied on this width. So, this animation occurs.
No need of extra markup (pseudo would do the job too anyway ), you could simply use a background-image (or gradient) and use
background-size
to expand/shrink the effect.background-position can be sused to set where effect can start (demo below does : left, center, right)