jQuery的淡出没有显示没有? [英] jQuery fadeOut without display none?

查看:59
本文介绍了jQuery的淡出没有显示没有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有不使用display:none的fadeOut()替代品?我只想使用隐藏的可见性来避免页面布局发生任何变化?

Is there an alternative to fadeOut() that doesn't use display:none for the style? I'd like to just use visibility hidden to avoid any sort of shifting in the page layout?

推荐答案

您可以使用 .animate() 直接在opacity

$(".selector").animate({ opacity: 0 })

这样,元素仍然占据您想要的空间,它只是具有0不透明性,因此有效与完成后成为visibility: hidden相同.

This way the element still occupies space like you want, it just has a 0 opacity, so it's effectively the same as it being visibility: hidden when it finishes.

这篇关于jQuery的淡出没有显示没有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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