我正在尝试更改悬停时元素的背景颜色。通常情况下,我会使用
className='bg-white hover:bg-black'
这会立即改变颜色,但我想添加 150 毫秒从颜色 A 到颜色 B 的过渡时间。
阅读文档后,我尝试了类似的方法
className='transition-colors ease-linear duration-300 bg-white hover:bg-gradient-to-r from-[#04348B] to-[#0854e2d0]'
这没有任何作用。我混合并匹配了不同的状态等,但找不到解决方案。有人知道这个问题的快速解决方法吗?
我试过:
className='transition-colors ease-linear duration-300 bg-white hover:bg-gradient-to-r from-[#04348B] to-[#0854e2d0]'
className='transition-[background-color] duration-300 bg-white hover:bg-gradient-to-r from-[#04348B] to-[#0854e2d0]'