使用 jQuery 高亮功能淡入透明
此线程似乎部分解决了我的问题,但没有答案线程和大多数评论更多的是讨论和问题,而不是试图解决OP的问题...
我的情况与上述帖子的不同之处在于我有一个需要淡入淡出的背景图像。就像现在一样,颜色变为我设置的颜色,淡入白色,然后变为背景图像。你可以在这个jsFiddle中看到它。
有什么方法可以从我设置的颜色过渡到透明,而不是先过渡到白色然后透明?
更新:
在与 musicinmyhead 发表评论后,我使用 UI 的位置效果工作了一段时间,但仍然无法让它在 FF 中工作。我为位置效果添加了以下代码(请参阅上面链接中更新的 jsFiddle):
$('.checkwrap').position({
'my': 'left top',
'at': 'left top',
'of': $('#classesTable td:eq(0)')
});
添加没有“效果”(请原谅双关语),所以我想知道我是否只是语法错误。我还尝试弄乱 css,看看是否会改变任何东西 - 嗯,它确实改变了,但我没有做任何修复它......
This thread seems to partially address my question, but there are no answers in that thread and most of the comments are more discussion and questions than trying to solve the OP's question...
The difference in my case from the above-mentioned post is that I have a background image that I need to fade to. As it is now, the color goes to my set color, fades to white, then to the background image. You can see it in this jsFiddle.
Is there any way to transition from my set color, then straight to transparent, rather than to white and then transparent?
UPDATE:
After the comments with musicinmyhead I worked with UI's Position effect for a while and am still unable to get it to work in FF. I added the following code for the Position effect (see the updated jsFiddle in the link above):
$('.checkwrap').position({
'my': 'left top',
'at': 'left top',
'of': $('#classesTable td:eq(0)')
});
Adding that had no "effect" (pardon the pun), so I'm wondering if I'm just getting the syntax wrong. I also tried messing with the css to see if that change anything - well, it did, but nothing that I did fixed it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于“透明”不是一种颜色,您可能无法像这样转换背景颜色。最好的选择是附加一个与包含复选框的表格单元格大小相同的元素,然后将该附加元素从 100% 不透明度设置为 0%(模拟从红色到背景的过渡)。然后您可以动态删除该元素。
我已经更新了你的 jsFiddle 所以你可以看到我在说什么,一个快速的 CSS 类是添加并确保“td”元素的样式设置为“位置:相对”(否则绝对定位的附加 div 会到处都是)。
另一个快速说明:还有一些其他方法可以做到这一点,例如动态调整附加元素的大小/位置,这些方法可能会更优雅,但目前这应该适合您的问题。
Since "transparent" isn't a color you probably won't be able to transition the background-color like that. Your best bet would be to append an element that is the same size as the table cell containing the checkbox and then animating that appended element from 100% opacity to 0% (simulating a transition from red to your background). You can then remove that element dynamically.
I've updated your jsFiddle so you can see what I'm talking about, a quick CSS class was added as well as making sure the "td" elements are styled to position:relative (otherwise the absolutely positioned appended div just goes all over the place).
Another quick note: There are a few other ways of doing this, such as sizing/positioning the appended element dynamically, and those would probably be a bit more elegant but this should suit your problem just fine for now.