css()和不透明度..在fadeIn()之后不起作用 [英] css() and opacity.. following fadeIn() not working

查看:188
本文介绍了css()和不透明度..在fadeIn()之后不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在css()中将不透明度设置为0时,以下fadeIn()不起作用

when I set opacity to 0 in css() the following fadeIn() doesn't work

如果我将不透明度设置为1,则会显示loader元素,但是当然不会有任何淡入.

if I set opacity to 1 the loader element is showed but there will of course not be any fading in..

loader.css({
        top : ($(window).height() - loader.height()) / 2+'px',
        left : ($(window).width() - loader.width()) / 2+'px',
        opacity : 0
    })
    .fadeIn(1000);

如果我使用display:none,那行不通!?

if I use display:none it works!?

loader.css({
        top : ($(window).height() - loader.height()) / 2+'px',
        left : ($(window).width() - loader.width()) / 2+'px',
        display : 'none'
    })
    .fadeIn(1000);

推荐答案

尝试使用fadeTo()

loader.css({
    top : ($(window).height() - loader.height()) / 2+'px',
    left : ($(window).width() - loader.width()) / 2+'px',
    opacity : 0
})
.fadeTo(1000, 1);

这篇关于css()和不透明度..在fadeIn()之后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆