I am attempting to create an animation for an <li>
element that gives the illusion of a fill effect moving from left to right when hovered over.
This is my current progress:
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;
/* Older browser support */
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 encountered a few challenges with this setup. Firstly, the fill effect is currently being applied from right to left instead of the desired left to right motion. Despite multiple attempts at adjusting the background positions, I have been unable to achieve the intended result.
Additionally, I aim to incorporate a small strip of the fill color visible initially, similar to the example by Jay Holtslander found here: https://codepen.io/j_holtslander/full/XmpMEp/
Lastly, the current code structure appears somewhat cumbersome and outdated, sourced from this response dated back in 2013 by beardhatcode. Is there a more contemporary and streamlined approach to achieving this specific effect?