在 IE7 中使用 jquery slipToggle 时内容消失

发布于 2024-09-12 01:53:27 字数 575 浏览 8 评论 0原文

我已经多次看到这个问题被问到,但没有看到任何答案。

我有一个 ul,我正在使用 sliderToggle() 和 jquery 来扩展和折叠它。 代码很简单:

$('#leftMenu li a.moreLess').click(function() {
    $(this).next().slideToggle('normal');   
});

使用以下标记:

<a class="moreLess">Click here to see more</a>
<ul>
  <li>something</li>
  <li>something else</li>
  ...
</ul>

我有一个带有 .moreLess 类的按钮,单击它时,下面的列表应该展开或折叠。由于某种原因,在 IE 7 中,一旦列表完全展开,所有内容都会消失。当它折叠时,内容会再次出现,直到列表完全关闭。

我不确定这是否与 CSS 相关,但我希望有人以前遇到过这个问题。 预先感谢您的帮助!

I've seen this question asked several times but haven't seen any answers.

I have a ul that I'm expanding and collapsing using slideToggle() with jquery.
The code is simple:

$('#leftMenu li a.moreLess').click(function() {
    $(this).next().slideToggle('normal');   
});

With markup of:

<a class="moreLess">Click here to see more</a>
<ul>
  <li>something</li>
  <li>something else</li>
  ...
</ul>

I have a button with a class of .moreLess and when it is clicked the list below it should expand or collapse. For some reason in IE 7 all of the content is disappearing once the list is fully expanding. When it collapses, the content appears again until the list is fully closed.

I'm not sure if this is something CSS related, but I was hoping someone might have run into this before.
Thanks in advance for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

心安伴我暖 2024-09-19 01:53:28

添加 zoom:1 属性。它适用于位置:相对。

put a zoom:1 property. it works with position:relative.

猥琐帝 2024-09-19 01:53:28

仅供参考,问题在于 CSS 定位在正在切换的 UL 内的元素上。一旦我删除了这些元素上的任何相对和/或绝对定位,问题就不再发生。

FYI the problem was with CSS positioning on the elements inside the UL that is being toggled. Once I removed any relative and/or absolute positioning on those elements, the problem no longer happened.

暗藏城府 2024-09-19 01:53:28


溢出:隐藏;
对于包含内容的 div,情况会变得混乱。对我有用,但仍然是 IE bug...

put
overflow: hidden;
for the div in which you have the content, that gets messed up. Works for me, but still it's and IE bug...

还如梦归 2024-09-19 01:53:28

在我的例子中,用slideToggle加载的内容被“移动”下来,创建了2个空白空间(仅在IE7中)

我用这个css解决了:

form {
    margin: 0;
}

in my case the content loaded with slideToggle was "shifted" down creating 2 empty space (only in IE7)

i solved with this css:

form {
    margin: 0;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文