css 引导3折叠其他

6ojccjat  于 2022-11-27  发布在  其他
关注(0)|答案(1)|浏览(154)

因此,我尝试创建一个折叠框,如下图所示。我需要显示几个这样的框,但希望在打开一个折叠框时隐藏其他框。尝试使用引导程序折叠,但看起来DOM结构是 * 必需的 *:https://github.com/twbs/bootstrap/issues/10966
有没有其他方法可以在没有javascript的情况下实现同样的行为?

这是我的标记:

<div class="col-xs-12 col-sm-8 col-lg-10">
    <div class="row">
        <div class="col-xs-4 col-lg-2"><span class="text-uppercase">Var dates</span><span>$600.00</span><span><a data-target="#moreInfoPastAmount" data-toggle="collapse" aria-expanded="true" aria-controls="moreInfoPastAmount" data-parent="#moreInfo">+Past Amount</a></span></div>
        <div class="col-xs-4 col-lg-2"><span class="text-uppercase">Var dates</span><span>$400.00</span><span><a data-target="#moreInfoLateFees" data-toggle="collapse" aria-expanded="true" aria-controls="moreInfoLateFees" data-parent="#moreInfo">+Late Fees</a></span></div>
        <div class="col-xs-4 col-lg-2"><span class="text-uppercase">Mar 26</span><span>$200.00</span><span>Current Due</span></div>
    </div>
    <div id="moreInfo" class="row">
        <div class="col-xs-12">
            <div id="moreInfoPastAmount" class="arrow-box collapse in" aria-expanded="true">
                <div class="arrow left"></div>
                <p>Content goes here</p>
            </div>
            <div id="moreInfoLateFees" class="arrow-box collapse in" aria-expanded="true">
                <div class="arrow left"></div>
                <p>Content goes here</p>
            </div>
        </div>
    </div>
</div>
njthzxwz

njthzxwz1#

经过一番研究之后,由于Bootstrap的collapse data-parent -https://github.com/twbs/bootstrap/issues/10966中的一个bug,您只需要在#moreInfo div中添加一个.panel类。

<div id="moreInfo" class="row">
        <div class="panel col-xs-12"> <!-- Panel added here -->
            <div id="moreInfoPastAmount" class="arrow-box collapse" aria-expanded="true">

Demo Here

相关问题