jQuery 1.9手风琴高度问题 [英] jquery 1.9 accordion height issue

查看:71
本文介绍了jQuery 1.9手风琴高度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用父母身高为400px的手风琴.我希望手风琴的高度不要大于400px,但我也希望手风琴的各个元素能够根据其内容的大小进行调整.通过将"heightStyle"设置为"fill",可以使整个手风琴的高度为400px.在这种情况下,手风琴的每个元素都具有相似的大小,如果元素的内容大于默认大小,则它可以滚动,但是如果内容较小,则会得到很多空白,这是我所不希望的.

I am using an accordion who's parent height is 400px. I want the accordion's height to never be greater than 400px, but I also want that the individual elements of the accordion adjust to the size of their content. I can get the whole accordion to be of height 400px by setting "heightStyle" to "fill." In this case each element of the accordion has a similar size, if the content of the element is larger than the default size it becomes scrollable, but if the content is smaller you get a lot of empty space, that I don't want.

我当然可以通过将"heightStyle"设置为"content"来使每个元素成为内容的大小,但是在这种情况下,手风琴的扩展大小可以大于400px.因此,我想要的是填充"和内容"的组合,您知道如何获得这种行为吗?

Of course I can make each element the size of the content by setting "heightStyle" to "content," but in this case the expanded size of the accordion can be greater than 400px. So what I want is a combination of "fill" and "content," do you know how to get this behavior?

谢谢.

推荐答案

您需要做的就是在CSS中设置max-height和溢出属性. 这是一个演示:

All you would need is to set the max-height and overflow properties in the css. Here is a demo:

#accordion .ui-accordion-content {
    max-height: 400px;
    overflow-y: auto;
}

仅出于演示目的,我将演示的最大高度设置为200px.

I set the demo max-height to 200px just for demo purposes.

这篇关于jQuery 1.9手风琴高度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆