I want to make text that changes its color in the middle of a word, in fact in the middle of a letter. I got it to work, but I also want to add a background color that changes in the same place. The issue is that I’ve used background image with a gradient to have the text colors change.
This is what I have so far with Tailwind CSS:
<script src="https://cdn.tailwindcss.com"></script>
<span class="bg-[linear-gradient(to_right,black_23%,pink_23%)] bg-clip-text text-[100px] text-transparent">powered</span>
2
Answers
HTML Structure:
Explanation:
1.Use text-transparent to make the text color transparent.
2.Apply a gradient background with bg-gradient-to-r and bg-clip-text to make the gradient appear on the text.
3.The relative and absolute classes ensure the gradient background covers the text properly.
I would advice you to use some custom CSS along with Tailwind CSS in order to achieve both text color and background color changes.
You’ve already used bg-clip-text and gradient background to change the text color in the middle.
Now I would suggest that in order to have the background color change at the same position, you need to use a similar gradient but applied to the background of the text.
I am listing down one code snippet, you can take a reference from this code.
I hope this will resolve your query.