通过 JQuery .fadeIn、.fadeOut 调整页面大小看起来很糟糕
我试图根据页面上单击的链接让不同的 div
元素淡入和淡出。它工作正常,但每当一个元素淡出而另一个元素同时淡入时,页面大小就会发生相当大的变化,并且看起来“有问题”。放置延迟基本上具有相同的效果,因为一旦一个淡出,页面的大小就会减小,然后另一个淡入的页面会增加。
我想尝试设置高度的 position:absolute
但我'我也希望拥有它,以便用户可以选择一次加载所有 div,并且它们会重叠。
我可以尝试其他看起来更平滑的动画,但我喜欢淡入淡出。
还有其他人有解决这个问题的经验吗?有没有办法延迟页面大小调整,哈哈?
I'm trying to have different div
elements fade in and out based on links that are clicked on the page. It works fine, but whenever 1 element is fading out and another is fading in at the same time, the page size gets altered pretty drastically and it looks "glitchy." Putting a delay basically has the same effect because the page will decrease in size once one fades out and then increase ones the other fades in.
I would like to try position:absolute
with a set height but I'd also like to have it so the user has an option to load ALL divs at once, and they would overlap.
I could try other animations that look smoother, but I like the fade.
Has anyone else had experience working around this? Is there a way to delay the page from resizing, lol?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了同样的问题。我解决这个问题的方法是使用outerHeight() JQuery函数获取父div的当前高度,然后在子div上调用fadeOut函数之前将div的最小高度设置为当前高度。
HTML
JQuery
这是我知道的一个老问题,但我希望能帮助任何在这里找到方法的人。
I was struggling with the same problem. The way I got around it was by getting the current height of the parent div using the outerHeight() JQuery function and then setting the min-height of the div to the current height before calling the fadeOut function on the child div.
HTML
JQuery
This is an old question I know, but I hope that helps anybody who has found there way here.