一、高度设置
1、JQuery版本1.8及以下
autoHeight: false
$("#component").accordion({
collapsible: true,
autoHeight: false,
active:0
});
2、JQuery版本1.9及以上
heightStyle:'content’
$("#component").accordion({
collapsible: true,
heightStyle:'content',
active:0
});
二、heightStyle
功能:控制accordion和每个panel的高度
类型:String
默认:“auto”
取值 | 含义 |
---|---|
auto | All panels will be set to the height of the tallest panel. 所有面板将设置为最高面板的高度 |
fill | Expand to the available height based on the accordion’s parent height.根据手风琴父级组件的高将其扩展到可用高度 |
content | Each panel will be only as tall as its content.每个面板的高度仅取决于其内容 |
例子:
accordion初始化带有heightStyle选项:
$( ".selector" ).accordion({
heightStyle: "fill"
});
初始化之后,获取/设定heightStyle:
// Getter
var heightStyle = $( ".selector" ).accordion( "option", "heightStyle" );
// Setter
$( ".selector" ).accordion( "option", "heightStyle", "fill" );