简体   繁体   English

为什么jQuery UI手风琴打开/关闭动画如此不稳定?

[英]Why is jQuery UI accordion open/close animation so choppy?

I've been trying to figure this one out and I just can't see any issues - as well, the same accordion (same jqueryui version 1.9.2) works with no issues on another site, I even switched the theme to use the same one as the other site and I still get the choppiness on this one. 我一直试图想出这个,我只是看不出任何问题 - 同样的手风琴(同样的jqueryui版本1.9.2)工作在另一个网站上没有问题,我甚至切换主题使用和其他网站一样,我仍然对这个网站感到不快。

And it shouldn't be the jquery ui theme either as it's working fine here 并且它不应该是jquery ui主题,因为它在这里工作得很好

Any ideas what it might be? 任何想法可能是什么?

For future readers, I have also experienced this issue when I hadn't wrapped the content of my accordion row in a div tag: 对于未来的读者,当我没有在div标签中包含手风琴行的内容时,我也遇到过这个问题:

Bad: 坏:

        <div class="accordion">
            <h3>Delivery Address</h3>
            <table class="address">
                <tr><td>...</td></tr>
            </table>
        </div>

Good: 好:

        <div class="accordion">
            <h3>Delivery Address</h3>
            <div>
                <table class="address">
                    <tr><td>...</td></tr>
                </table>
            </div>
        </div>
.ui-accordion .ui-accordion-content {
    padding: 1em 2.2em;
}

The issue is with this css. 问题在于这个css。 If you change it to px instead of em, it functions correctly. 如果将其更改为px而不是em,则它可以正常运行。

I was having a similar issue. 我遇到了类似的问题。 After looking a few different solutions. 看了几个不同的解决方案。 I found it was a margin issue. 我发现这是一个保证金问题。

This worked for me: 这对我有用:

#accordion .ui-accordion-header {
    margin:0;
}

I have the hightstyle set to content by the way. hightstyle我的hightstyle设定是满足的。

Hope this helps! 希望这可以帮助!

In my case this was caused by the margin of my accordion titles, and the margin of the elements inside my accordion content. 在我的情况下,这是由我的手风琴标题的边缘,以及我的手风琴内容中的元素边缘引起的。 You will need to set the margins of those elements to 0. If you want to add space between those elements you can use padding and it wont cause issues. 您需要将这些元素的边距设置为0.如果要在这些元素之间添加空格,可以使用填充,它不会导致问题。

#accordion h3 {
margin: 0;
padding: 10px 0;
}
#accordion p {
    margin: 0;
    padding: 10px 0;
}

I used paragraphs tags inside the divs of the accordion content. 我在手风琴内容的div中使用了段落标签。 If you use something else, make sure the margin of that element is set to 0. 如果您使用其他内容,请确保该元素的边距设置为0。

The key to the smooth action is the "heightStyle" EG 平滑动作的关键是“heightStyle”EG

$( "#accordion" ).accordion({
    heightStyle: "content"
});

I think you have forgotten to add all file dependencies, in tag 我认为您忘记在标记中添加所有文件依赖项

<script type='text/javascript' src='http://www.georgiancollege.ca/programs/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
<script type='text/javascript' src='http://www.georgiancollege.ca/programs/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://www.georgiancollege.ca/programs/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://www.georgiancollege.ca/programs/wp-includes/js/jquery/ui/jquery.ui.accordion.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://www.georgiancollege.ca/programs/wp-includes/js/jquery/ui/jquery.ui.button.min.js?ver=1.9.2'></script>

include all dependencies then it should work fine.. 包括所有依赖项然后它应该工作正常..

I had a similar issue with a nested accordion in Drupal which was built using Views Nested Accordion. 我在Drupal中使用Views Nested Accordion构建了一个类似的嵌套手风琴问题。 I removed line 38 of the views-nested-accordion.css which has .ui-accordion .ui-accordion-content {height: auto !important;} and it fixed my issue. 我删除了带有.ui-accordion .ui-accordion-content {height: auto !important;}的views-nested-accordion.css的第38行,它解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM