简体   繁体   English

Bootstrap手风琴使用th:block折叠

[英]Bootstrap accordion collapse with th:block

Hello i have a problem with print objects on website. 您好,我在网站上的打印对象有问题。 I have a packets from DB and i want print them in to the Accordion collapse (example on Boostrap). 我有一个来自DB的数据包,我想将它们打印到Accordion折叠中(例如Boostrap上的示例)。 Now i have all objects or any objects open on the website. 现在,我在网站上打开了所有对象或任何对象。

    <div id="accordion">
    <th:block th:each="packet: ${packet}">
        <div class="card">
            <div class="card-header">
                <h5 class="mb-0">
                    <button class="btn btn-link" data-toggle="collapse" data-target="#collapse" aria-controls="collapse" th:text="${packet.name}">
                    </button>
                </h5>
            </div>
            <div id="collapse" class="collapse show" aria-labelledby="heading" data-parent="#accordion">
                <div class="card-body" th:text="${packet.description}">
                </div>
            </div>
        </div>
    </th:block>
    </div>

在此处输入图片说明

It is a problem with the css classes you are using inside the block. 您在块内使用的css类存在问题。 Use show only to show the card you want and you have to use collapsed in the buttons inside collapsed cards. 使用show只显示你想要的牌,你必须使用collapsed在里面的按钮倒塌卡。 The following code will show all the items collapsed: 以下代码将显示所有折叠的项目:

  <div id="accordion">
    <th:block th:each="packet: ${packet}">
        <div class="card">
            <div class="card-header">
                <h5 class="mb-0">
                    <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse" aria-controls="collapse" th:text="${packet.name}">
                    </button>
                </h5>
            </div>
            <div id="collapse" class="collapse" aria-labelledby="heading" data-parent="#accordion">
                <div class="card-body" th:text="${packet.description}">
                </div>
            </div>
        </div>
    </th:block>
    </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM