I am trying to animate an <li>
so that on hover it appears that there is a fill effect going from left to right.
This is what I have so far.
ul {
list-style-type: none;
}
.hoverTest {
float: left;
margin-right: 1px;
}
.hoverTest li {
width:100px;
padding: 11px 16px;
text-align:center;
float:left;
background: #ff3232;
/* Old browsers */
background: linear-gradient(to left, red 50%, blue 50%);
background-size: 200% 100%;
background-position:left bottom;
margin-left:10px;
transition:all 0.5s ease;
}
.hoverTest li:hover {
background-position:right bottom;
}
.hoverTest li a {
color:white;
}
<div class="hoverTest">
<ul>
<li><a href="#">Test Button</a></li>
</ul>
</div>
I have a number of issues with this. First of all the fill effect is coming from right to left whereas I would like the opposite. No matter what I have tried with changing the positions of the backgrounds I just cannot get this to work.
Secondly, I would like there to be a small strip of the fill colour displayed to begin with as in this example by Jay Holtslander : https://codepen.io/j_holtslander/full/XmpMEp/
Finally the code I have at the moment seems to be relatively clunky, it is taken from this answer in 2013 by beardhatcode. Is there a more modern, simpler way to implement this effect?