具有 autoHeight=true 的 jQuery UI 手风琴在非默认窗格上有不必要的滚动条

发布于 2024-07-17 12:39:12 字数 495 浏览 6 评论 0原文

我在使用 jQuery 手风琴时遇到问题。 当我创建一个内容窗格时,非默认窗格的内容比默认窗格多,并且 autoHeight 为 true,这在切换窗格时提供了很好的动画,但非默认窗格获得了我不想要的滚动条。

您可以通过转到 http://jqueryui.com/themeroller/ 切换到主题来查看此操作例如“Blitzer”或“Humanity”,然后打开示例手风琴的第 3 部分。 我使用的是 Safari 3.2.1 和 Firefox 3.0.8。

如果切换到 autoHeight=false,则不会发生这种情况,并且所有内容窗格都具有正确的高度,但内容窗格仅在动画结束时渲染并且看起来很奇怪,因此我必须关闭动画以避免这种奇怪的情况。

要么是我误读了某些内容,要么这是 jQuery UI 手风琴中的一个错误。 请帮我找出是两者中的哪一个(或者两者都是)。

I am having trouble with jQuery accordion. When I create a content pane where the non-default pane has more content than default pane, and autoHeight is true, this provides nice animations when switching panes, but the non-default pane gets a scrollbar which I don't want.

You can see this in action by going to http://jqueryui.com/themeroller/, switching to a theme like "Blitzer" or "Humanity", and then opening Section 3 of the example accordion. Happens to me with Safari 3.2.1 and Firefox 3.0.8.

If you switch to autoHeight=false, then this does not happen and all content panes have the correct height, but the content pane is only rendered at the end of the animation and looks strange, so I had to turn off animations to avoid this strangeness.

Either I am misreading something, or this is a bug in jQuery UI accordion. Please help me figure out which of the two it is (or maybe both).

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

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

发布评论

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

评论(11

忆梦 2024-07-24 12:39:12

我尝试了几种不同的方法。 autoHeight: false 本身不起作用。 这最终对我有用:

$( "#accordion" ).accordion({
            heightStyle: "content",
            autoHeight: false,
        clearStyle: true,   
        });

我在具有固定宽度的 SharePoint 内容编辑器 Web 部件中使用它,这在向手风琴小部件添加内容时增加了高度问题。

I tried several different things. autoHeight: false by itself did not work. This is what finally worked for me:

$( "#accordion" ).accordion({
            heightStyle: "content",
            autoHeight: false,
        clearStyle: true,   
        });

I'm using this in a SharePoint content editor webpart with a fixed width, which added to the height issue when adding content to the accordion widget.

一身仙ぐ女味 2024-07-24 12:39:12

使用这个组合选项对我有用,1.jquery/ui的当前版本

$( '#x' ).accordion({
    autoHeight: false,
    clearStyle: true
});     

using this combo options works for me, 1.current version of jquery/ui

$( '#x' ).accordion({
    autoHeight: false,
    clearStyle: true
});     
迟到的我 2024-07-24 12:39:12

我遇到了类似的问题,对我来说,CSS 的以下更改有效。

.ui-accordion .ui-accordion-content{
overflow:visible !important;
}

I faced similar problem, for me the following change in CSS worked.

.ui-accordion .ui-accordion-content{
overflow:visible !important;
}
零度℉ 2024-07-24 12:39:12

如今(使用 jQuery UI - v1.8),只需 autoHeight 就足够了,不再出现滚动条。

jQuery("#accordion").accordion(
  {
    autoHeight:false
  }
);

Nowadays (with jQuery UI - v1.8), just autoHeight is enough, no more scrollbars are appearing.

jQuery("#accordion").accordion(
  {
    autoHeight:false
  }
);
久隐师 2024-07-24 12:39:12

使用 heightStyle: "content" 帮助解决了我的问题。
参考:手风琴

Having heightStyle: "content" helped resolve my issue.
Reference: Accordion

灼痛 2024-07-24 12:39:12

我知道这已经很旧了,但我遇到了这个问题并降落在这里。 可以在这里找到不会破坏动画并摆脱动画的解决方案:

http://webdevscrapbook.wordpress.com/2012/02/24/jquery-ui-unnecessary-scrollbar-in-accordion/

对于那些不想点击的懒惰的人来说,简短的回答是:

.ui-accordion .ui-accordion-content { overflow:hidden !important; }

在手风琴的 CSS 中

I know this is old, but I was having this problem and landed here. A solution that doesn't break your animation and gets rid of the animation can be found here:

http://webdevscrapbook.wordpress.com/2012/02/24/jquery-ui-unnecessary-scrollbar-in-accordion/

For those lazy few who don't want to click, the short answer is:

.ui-accordion .ui-accordion-content { overflow:hidden !important; }

in the accordion's CSS

新一帅帅 2024-07-24 12:39:12

我从 http:// helpdesk.objects.com.au/javascript/how-to-avoid-scrollbars-when-using-jquery-accordion 上面提到的链接。 这是该文章下的评论之一。 它去掉了滚动条,但也保留了其余的 div 格式。 上面的答案可能会导致内容跨越边界流动,就像我所发生的那样。

.ui-accordion .ui-accordion-content{
height:auto!important;
}

I got this from the http://helpdesk.objects.com.au/javascript/how-to-avoid-scrollbars-when-using-jquery-accordion link mentioned above. It was one of the comments under the article. It gets rid of the scroll bar but also keeps the rest of the divs formatting. The above answers can cause content to flow over borders as was happening me.

.ui-accordion .ui-accordion-content{
height:auto!important;
}
热鲨 2024-07-24 12:39:12

这对我有用:

.ui-accordion-content-active, .ui-accordion-header-active{
    display: block;
}

This works for me:

.ui-accordion-content-active, .ui-accordion-header-active{
    display: block;
}
流殇 2024-07-24 12:39:12

我尝试过

.ui-accordion .ui-accordion-content{ overflow:visible !important; }

,但我在第一个选项卡上看到了一些视觉伪影。 所以我这样解决了这个问题:

<script type="text/javascript">
    (function() {
        var fixScroll = function(event, ui) {
            $(event.target).find('.ui-accordion-content-active').css('overflow', 'visible');
         }
        $('#tabs').accordion({ 
            header: "h2",
            create: fixScroll,
            change: fixScroll
        });
    })();
</script>

I tried

.ui-accordion .ui-accordion-content{ overflow:visible !important; }

but I saw some visual artifacts with first tab. So I fixed the problem this way:

<script type="text/javascript">
    (function() {
        var fixScroll = function(event, ui) {
            $(event.target).find('.ui-accordion-content-active').css('overflow', 'visible');
         }
        $('#tabs').accordion({ 
            header: "h2",
            create: fixScroll,
            change: fixScroll
        });
    })();
</script>
π浅易 2024-07-24 12:39:12

检查 ui-accordion-content 的填充是否被覆盖。

当我将以下内容放入 css 中时,我遇到了同样的问题:

.container .ui-widget-content {
    padding-right: 3%;
}

我将其更改为如下所示,并且滚动条消失了!

.container .ui-widget-content:not(.ui-accordion-content) {
    padding-right: 3%;
}

我也没有打开自动高度。

Check if the padding for the ui-accordion-content is being overridden.

I experienced the same issue when I had put the following in my css:

.container .ui-widget-content {
    padding-right: 3%;
}

I changed it as shown below and the scroll bars were gone!

.container .ui-widget-content:not(.ui-accordion-content) {
    padding-right: 3%;
}

I don't have auto-height turned on either.

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