You aim to style a progress bar with varying left-hand colors, and the text's color should adjust dynamically based on the underlying background.
You initially experimented with mix-blend-mode: difference to blend the text color with the background, but it proved unsuccessful. You also considered using filter: grayscale(1) contrast(9);, but that didn't yield the desired effect either.
An effective solution lies in creating an additional gradient to color the text. By employing this method, you eliminate the need for mix-blend mode.
The custom CSS code achieves this gradient override:
.container { width: 200px; height: 20px; background: linear-gradient(to right, #43a047 50%, #eee 0); text-align: center; } .text { background: linear-gradient(to right, white 50%, black 0); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; font-weight: bold; }
This approach ensures that the text color transitions between black (in darker left-hand sections) and white (in lighter left-hand sections).
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3