使用jQuery的元素的可见性 [英] Fading visibility of element using jQuery

查看:153
本文介绍了使用jQuery的元素的可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查找JQuery的可见性参数时遇到了一些麻烦。

I'm having some trouble with finding the visibility param for JQuery.

基本上...下面的代码什么都不做。

Basically... the code below does nothing.

$('ul.load_details').animate({
    visibility: "visible"
    },1000);

animate代码没有问题(我用fontSize替换了可见性,

There's nothing wrong with the animate code (I replaced visibility with fontSize and it was fine. I just can't seem to find the correct param name equivalent for "visibility" in css.

推荐答案

您可以将不透明度设置为0.0即不可见)和可见性(使不透明度相关),然后将不透明度从0.0到1.0动画化(使其淡入):

You could set the opacity to 0.0 (i.e. "invisible") and visibility to visible (to make the opacity relevant), then animate the opacity from 0.0 to 1.0 (to fade it in):

$('ul.load_details').css({opacity: 0.0, visibility: "visible"}).animate({opacity: 1.0});

因为您将不透明度设置为0.0,即使设置为visible,也是不可见的。不透明度动画应该为您呈现淡入

Because you set the opacity to 0.0, it's invisible despite being set to "visible". The opacity animation should give you the fade-in you're looking for.

或者,您可以使用 .show() .fadeTo() animations。

Or, of course, you could use the .show() or .fadeTo() animations.

EDIT: Volomike c> opacity 取一个介于0.0和1.0之间的值,而不是介于0和100之间。

Volomike is correct. CSS of course specifies that opacity takes a value between 0.0 and 1.0, not between 0 and 100. Fixed.

这篇关于使用jQuery的元素的可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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