javascript - Jquery 选项卡 : autoHeight for expanding content

标签 javascript jquery

我正在使用这个 SITE 中的 jquery 滑动标签,效果很好。唯一的问题是 autoHeight jquery 函数不适应扩展内容。 换句话说: 选项卡容器将调整到非事件内容的高度,但问题是一旦容器内的内容变为事件状态并垂直扩展,它将不再适合并且看不到 <--- 它无法适应这一点。这是示例 JSFFIDLE

我尝试这样做来调整高度以扩展内容,但它不起作用:

<script>
 var height = 50 // Set to the height you want
        $('.st_view').css('height', height+'px')

    });​

    </script>

整体 Jquery

 <script>

    $(document).ready(function() {

        $('div#st_horizontal').slideTabs({
            // Options              
            contentAnim: 'slideH',
            autoHeight: true,
            contentAnimTime: 600,
            contentEasing: 'easeInOutExpo',
            tabsAnimTime: 300
        });

        var height = 50 // Set to the height you want
        $('.st_view').css('height', height+'px')

    });​

    </script>

最佳答案

如果只有切换器导致内容展开,您可以像这样修改切换器代码:

$('#title').click(function() {
    $(this).toggleClass('active');
    $('#content').toggle();
    var $tab = $(this).closest('.st_tab_view');
    $tab.closest('.st_view').css('height', $tab.height());
});

要获得更通用的解决方案,请获取 jQuery resize plugin ,并添加此代码:

$('.st_tab_view').resize(function() {
    var $this = $(this);
    $this.closest('.st_view').css('height', $this.height());
});

关于javascript - Jquery 选项卡 : autoHeight for expanding content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11266702/

相关文章:

javascript - 排序比较如何从数组中获取参数

javascript - Crockford原型(prototype)继承...没有原型(prototype)链?没有 super ?

java - 使用 java 初始化 JavaScript 变量

javascript - JQUERY inputmask 是否可以为日期时间添加字符串?

javascript - 通过单击事件分配 Rails 变量?

javascript/mootools |自定义事件

javascript - 如何在 Javascript 循环中重绘 HTML 元素?

javascript - 如何知道用户是否完成了所有任务?

javascript - 无法使用 jQuery 设置 &lt;textarea&gt; 的宽度、高度

javascript - 当输入字段为空时如何禁用按钮?