jquery 动画不透明度无法跨浏览器工作
我知道这个问题已经被问过,但答案始终是 animate() 处理 opacity:0 和 filter:alpha(opacity=0) 之间的跨浏览器差异,在这种情况下不是这样......
我有这个 div
.entry
{
opacity:0.4;
filter:alpha(opacity=0);
}
和这个 jquery
<script>
$(document).ready(function(){
setTimeout(function(){
$('.entry').animate({opacity:'1'},700);
},1000);
});
</script>
文本在 IE 中保持不可见 alpha(opacity=0),在 chrome 和 firefox 中工作 可以在示例域查看。
编辑 我尝试过引用和取消引用 opacity:'1' 没有帮助
fadeIn() 不是一个选项,因为我需要保持 div 相同的高度,而且我不能太多地改变 CSS 来保持相同的高度,因为它弄乱了我的手风琴菜单。
谢谢,这就是最终工作的x浏览器,
<script>
$(document).ready(function(){
$('.entry').css({'opacity':0, 'filter':'alpha(opacity=0)'});
setTimeout(function(){
$('.entry').animate({opacity:'1'},700);
},1000);
});
</script>
不知道为什么你必须像这样在 'opacity':0, 'filter':'alpha(opacity=0)'
周围使用引号,但这是唯一的方法它起作用了。
我还必须将它放在 id# 元素上的不同 jquery 高亮效果之后。当它被放置在我的标题中的该函数之前时,它使该函数无法工作。也许与 css() 函数有关?
I know this question has been asked but the answer is always that animate() handles cross browser differences between opacity:0 and filter:alpha(opacity=0) not so in this case...
I have this div
.entry
{
opacity:0.4;
filter:alpha(opacity=0);
}
and this jquery
<script>
$(document).ready(function(){
setTimeout(function(){
$('.entry').animate({opacity:'1'},700);
},1000);
});
</script>
the text remains invisible alpha(opacity=0) in I.E, works in chrome and firefox
can view at sample domain.
edit
I have tried quoting and unquoting opacity:'1' does not help
fadeIn() not an option because i need to keep the div the same height and I can not change the CSS too much to keep the same height because it messes up my accordion menu.
thanks this is what ended up working x browser
<script>
$(document).ready(function(){
$('.entry').css({'opacity':0, 'filter':'alpha(opacity=0)'});
setTimeout(function(){
$('.entry').animate({opacity:'1'},700);
},1000);
});
</script>
not sure why you have to use quotes around 'opacity':0, 'filter':'alpha(opacity=0)'
like this but that's the only way it worked.
also I had to put it after a different jquery highlight effect i had on an id# element. when it was placed before that function in my header it kept that one from working. maybe something to do with the css() function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了代码一致性和消除跨浏览器问题,还可以使用 jQuery 而不是 CSS 设置初始不透明度...
For code consistency and elimination of cross-browser issues, also set your initial opacity with jQuery instead of CSS...
不确定这是否适用于较旧的 IE 版本,但它适用于 IE9 上的 IE 7 模式...
Filter:alpha(opacity=#) 对于 IE 来说是 0-100,因此将其设置为 1 可能只是设置它到... 1,当你想要它为100时。
我只是尝试制作这个jsFiddle: http://jsfiddle.net/N6GBU/1/,div 文本淡入(无论如何在 IE9 上)...我刚刚向动画添加了过滤器。我不确定这是否是你真正想要的……
Not sure if this is going to work in older IE versions, but it works in IE 7 mode on IE9...
Filter:alpha(opacity=#) is 0-100 for IE, so setting it to 1 may just be setting it to ... 1, when you want it as 100.
I just tried making this jsFiddle: http://jsfiddle.net/N6GBU/1/, and the div text fades in (on IE9 anyway)... I just added filter to the animate. I'm not sure if this is what you were after exactly though...