gpt4 book ai didi

css - Bootstrap 3 折叠 - 只折叠一个面板

转载 作者:太空宇宙 更新时间:2023-11-04 11:06:35 24 4
gpt4 key购买 nike

我需要折叠面板,一次只能折叠一个面板。但是我的崩溃允许同时打开多个面板。

我不知道我做错了什么。这是我的代码:

<div class="col-lg-8 col-md-12 col-sm-12 col-xs-12">
<div class="panel-group" id="h-promocje" role="tablist" aria-multiselectable="true" style="">
<?php foreach ($promocje as $key => $promocja) { ?>
<div class="panel-default">
<a class="accordion-toggle collapsed" role="button" style="text-decoration:none !important;" data-toggle="collapse" data-parent="#h-promocje" href="#promocja<?=$key?>" aria-expanded="true" aria-controls="promocja<?=$key?>">
<div class="panel-heading" role="tab" id="h-promocja<?=$key?>" style="border-bottom: 1px solid white;padding-left: 0;padding-right: 0;">
<h4 class="panel-title" style="color:white;font-size:18px;font-weight:bold;text-transform: uppercase;padding-top: 4px; padding-bottom: 3px;text-align: left;">
<?=$promocja->tytul?>
</h4>
</div>
</a>
<div id="promocja<?=$key?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="promocja<?=$key?>">
<div class="panel-body">
<?=$promocja->opis?>
</div>
</div>
</div>
<?php } ?>
</div>

最佳答案

您正在使用 Bootstrap。而 Bootstrap 的折叠需要在可折叠结构中声明 .panel 类并在结构中使用 data-parent="" 属性,否则它不会像 Accordion 一样工作.您还没有添加面板类,使用面板默认类添加它。

.container-full {
width: 90%!important;
/* for demo */
margin: 0 auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<div class="container-full">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table,
raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Collapsible Group Item #2
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table,
raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Collapsible Group Item #3
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table,
raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
</div>

这是来自 Bootstrap 网站的实例。尝试删除面板类。

关于css - Bootstrap 3 折叠 - 只折叠一个面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33928313/

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