CSS3 Webkit-过渡淡入/淡出
我在使用 CSS3 实现非常简单的淡入淡出效果时遇到了一些麻烦。这是我的场景:
我有一个列表 a,其中包含一些内容。我还有一些链接,单击这些链接会过滤列表中的内容。我想要的是,当页面加载时,列表会淡入,并且每次过滤列表时,列表都应该消失,而不是随着新内容淡入。
我在页面加载时实现了淡入淡出功能。然而,当我尝试让列表消失并再次淡入时,我无法让它工作。
这是我创建的一个 jsfiddle 来演示我正在尝试做的事情。 - http://jsfiddle.net/YeKX2/28/
对此的任何帮助表示赞赏。
I am having a little trouble achieving a very simply fade effect using CSS3. Here is my scenario:
I have a list a with some content in it. I also have some links, that when clicked filter the content in the list. What I would like is, when the page loads the list fades in, and every time the list is filtered, the list should disappear and than fade in with the new content.
I got the fade in on pageload working. However when I try to get the list to disappear and fade in again, I cant get that to work.
Here is a jsfiddle I created to demonstrate what I am trying to do. - http://jsfiddle.net/YeKX2/28/
Any help on this is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
保持它主要基于 webkit,而不是像您看起来那样使用 jQuery,您可以执行以下操作来实现您的目标:
您必须考虑时机。
另外,需要注意的是,如果您想影响 -webkit-transition 的时间,可以使用以下语法。
Keeping it primarily webkit based and not using jQuery as you seem to be, you could do the following to achieve your goals:
You'll have to play around with the timing.
Also, to note, if you want to effect the timing of the -webkit-transition, you can use the following syntax.
如果可能的话,我强烈建议包含 jQuery 库。然后淡入淡出就像:
jQuery("#elementId").animate({opacity:0});
jQuery("#elementId").animate({opacity:1});
否则,您最终会遇到浏览器问题,因为某些浏览器(IE)对不透明度的处理方式不同,并且 webkit-transition 是一个实验性的 mozilla 属性。
I highly recommend including the jQuery library if at all possible. Then fading is as easy as:
jQuery("#elementId").animate({opacity:0});
jQuery("#elementId").animate({opacity:1});
Otherwise you'll end up with browser issues as opacity is handled differently in some browsers(IE) and webkit-transition is an experimental mozilla property.