I am working on an input field with a gradient border on hover and focus. I came up with this snippet that technically works:
<div class="rounded-lg bg-gradient-to-tr from-yellow-600 via-red-600 to-purple-600">
<input class="rounded-lg border border-gray-300 bg-clip-padding px-4 py-2 transition duration-200 hover:border-transparent focus:border-transparent focus:outline-none" />
</div>
https://play.tailwindcss.com/g4r07nPkLe
However, it produces tiny halo-like double borders on every corner. Please take a look at the attached image:
Through trial and error, I discovered that the background gradient image causes it. If it is removed, the tiny halos go away. It is not there when hovered or focused, either. Is there any way to fix it?
2
Answers
It is necessary to use an additional element, or a pseudo-element. For example:
You use like this→