Fill Background Color Left to Right with CSS
You seek to make the background of an li element fill from left to right with a different color on hover. To achieve this, you'll utilize a linear gradient and animate the background position.
Code Implementation:
<code class="css">background: linear-gradient(to left, red 50%, blue 50%) right; background-size: 200% 100%;</code>
<code class="css">background-position: left;</code>
Vendor Prefixes:
Vendor prefixes might be necessary if you want to ensure cross-browser compatibility. Refer to the comments in your question for guidance on specific vendor prefixes.
Additional Options:
The above is the detailed content of How to achieve a left-to-right color fill animation on an li element using CSS?. For more information, please follow other related articles on the PHP Chinese website!