gpt4 book ai didi

javascript - jquery bootstrap Accordion 没有完全垂直扩展

转载 作者:行者123 更新时间:2023-11-30 12:10:02 26 4
gpt4 key购买 nike

我将这个示例 fiddle 用于嵌套的自举 Accordion 。 Fiddle here

我在 MVC/Razor 中使用它,但我无法让子 Accordion 完全展开。他们只打开一点点,需要滚动,这是不希望的。

这是我相关的 Razor 片段:(仅供引用,我添加的各种 style="height:150px;" 属性试图让 Accordion 展开,但它们只扩展了 Accordion 周围的区域,不是 Accordion 本身。)

<style>

.accordion-expand-holder {
margin: 10px 0;
}

/*.accordion-expand-holder .open, .accordion-expand-holder .close {
margin: 0 10px 0 0;
}*/

.ui-accordion-content {
height: auto;
}
</style>
<link href="~/Content/jquery-ui.css" rel="stylesheet" />
<script src="~/Scripts/jquery-ui.js"></script>

<div class="accordion-expand-holder">
<button type="button" class="open">Expand all</button>
<button type="button" class="close">Collapse all</button>
</div>
@foreach (var item in Model)
{
<div class="accordion">
<h3>@(item.Name)</h3>
<div>
<div class="text-nowrap">
<button type="button" onclick="javascript:DeleteUserStory('@(item.Id)');">Delete</button>
<button type="button" onclick="javascript:EditUserStory('@(item.Id)');">Edit</button>
</div>
<div>Description: @(item.Description)</div>
<div>Notes: @(item.Notes)</div>
<div class="accordion" style="height:150px;">
<h3>Tasks</h3>
<ul style="height:150px;">
@if (item.Tasks != null)
{
if (item.Tasks.Count > 0)
{
foreach (var task in item.Tasks)
{
<li style="height:150px;">
<button type="button" onclick="javascript:DeleteTask('@(task.Id)');">Delete</button>
<button type="button" onclick="javascript:EditTask('@(task.Id)');">Edit</button>
<br />
<a href="#">@(task.Name)</a>
<br />
Description: @(task.Description)
</li>
}
}
else
{
<li>No Tasks Assigned.</li>
}
}
</ul>
</div>
<br />
<button type="button" onclick="javascript:ShowTaskModalForAdd('@(item.Id)');">Add New Task</button>

</div>
</div>
}


<script>
// Accordion - Expand All #01
$(function () {
$(".accordion").accordion({
collapsible: true,
active: false,
autoHeight: true,
});
var icons = $(".accordion").accordion("option", "icons");
$('.open').click(function () {
$('.ui-accordion-header').removeClass('ui-corner-all').addClass('ui-accordion-header-active ui-state-active ui-corner-top').attr({
'aria-selected': 'true',
'tabindex': '0'
});
$('.ui-accordion-header-icon').removeClass(icons.header).addClass(icons.headerSelected);
$('.ui-accordion-content').addClass('ui-accordion-content-active').attr({
'aria-expanded': 'true',
'aria-hidden': 'false'
}).show();
$(this).attr("disabled", "disabled");
$('.close').removeAttr("disabled");
});
$('.close').click(function () {
$('.ui-accordion-header').removeClass('ui-accordion-header-active ui-state-active ui-corner-top').addClass('ui-corner-all').attr({
'aria-selected': 'false',
'tabindex': '-1'
});
$('.ui-accordion-header-icon').removeClass(icons.headerSelected).addClass(icons.header);
$('.ui-accordion-content').removeClass('ui-accordion-content-active').attr({
'aria-expanded': 'false',
'aria-hidden': 'true'
}).hide();
$(this).attr("disabled", "disabled");
$('.open').removeAttr("disabled");
});
$('.ui-accordion-header').click(function () {
$('.open').removeAttr("disabled");
$('.close').removeAttr("disabled");

});
});
//$("#accordion").accordion();

最佳答案

需要这个:

$(".accordion").accordion({
collapsible: true,
active: false,
autoHeight: false,
heightStyle: "content" //<- this fixes the problem with the squished height
});

关于javascript - jquery bootstrap Accordion 没有完全垂直扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34070162/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com