JQuery版本与accordion高度设置

本文详细介绍了在不同JQuery版本下如何设置Accordion组件的高度,包括1.8及以下版本的autoHeight设置为false,以及1.9及以上版本使用heightStyle:'content'。同时,解释了heightStyle属性的作用,它用于控制accordion及其每个panel的高度,并讨论了其默认值和使用示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、高度设置

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”

取值含义
autoAll panels will be set to the height of the tallest panel. 所有面板将设置为最高面板的高度
fillExpand to the available height based on the accordion’s parent height.根据手风琴父级组件的高将其扩展到可用高度
contentEach 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" );
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值