我正在对我的表数据实施Bootstrap折叠。但是,当我按下按钮时,表数据确实折叠了,但是没有过渡。我已经确认我包括了jQuery,我使用的是折叠而不是折叠,并且使用的是aria-hidden =“ true” data-toggle =“ collapse”数据目标和ID。这不是屏幕宽度问题。
这里是我的代码笔https://codepen.io/mezavanessa/pen/RwrYgqM以及HTML和CSS的链接。
<section id="tableExpandedRows">
<table class="table table-expanded expanded-row-bg-color">
<thead>
<tr>
<th>heading one</th>
<th>heading two</th>
<th>heading three </th>
<th>heading four</th>
<th>heading five</th>
<th>heading six</th>
<th class="sr-only">Supplier ID</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<button class="btn-collapse icon-caret-width" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
<img src="assets/img/icon-caret-down.svg" alt="" class="icon icon-caret-down">
</button>
209
</td>
<td>Gate Parts for Repair</td>
<td>Magnolia Heritage Construction</td>
<td>$32,456.92</td>
<td>Jul 15, 2019</td>
<td>Geralt Rivera </td>
<td class="sr-only">2165465536484</td>
</tr>
<tr class="collapse" id="collapseOne" role="cell" aria-hidden="true">
<td colspan="3" class="collapse-data">
<div class="table-expanded-data">
<h5>Supplier ID</h5>
<p>608</p>
</div>
<div class="table-expanded-data">
<h5>Ship To</h5>
<address>
Fairview Gardens<br>
567 Fairview Circle<br>
Columbia, SC 29073
</address>
</div>
<div class="table-expanded-data">
<h5>Ship To Code</h5>
<p>907</p>
</div>
</td>
</tr>
</section>
.table {
background: $off-white;
border: none;
thead {
background-color: rgba(5, 116, 176, 0.2);
border: 1px solid rgba(5, 116, 176, 0.1);
th {
border: none;
}
}
th {
font-size: 0.875em;
}
th,
td {
padding: 1rem;
}
tr:first-child {
td {
border-top: none;
}
}
}
th {
border: none;
}
td {
border-color: rgba(52, 77, 91, 0.36);
}
.table-expanded-open tr:nth-child() {
background-color: $table-accent-bg;
}
// Expanded Rows//
.btn-collapse .icon-caret-down {
transition: transform 0.2s ease-out;
}
.btn-collapse[aria-expanded="true"] .icon-caret-down {
transform: rotate(0.5turn);
}
.table-expanded-data {
display: inline-block;
padding: 0 1em;
vertical-align: top;
}
答案 0 :(得分:0)
这是尝试折叠表时的已知问题,最好的选择是在TR内添加DIV并折叠该DIV。固定的代码笔https://codepen.io/feardarkness/pen/ExPeMry
<section id="tableExpandedRows">
<h2>Expanded Rows</h2>
<p>
Users may interact with a table with Expanded Rows to display additional content by clicking on the Down-Caret icon to expand a row vertically. Hidden elements like those with the sr-only class are required to ensure all content can be read by a screen reader.
</p>
<table class="table table-expanded expanded-row-bg-color">
<thead>
<tr>
<th>heading one</th>
<th>heading two</th>
<th>heading three </th>
<th>heading four</th>
<th>heading five</th>
<th>heading six</th>
<th class="sr-only">Supplier ID</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<button class="btn-collapse icon-caret-width" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
<img src="assets/img/icon-caret-down.svg" alt="" class="icon icon-caret-down">
</button>
209
</td>
<td>Gate Parts for Repair</td>
<td>Magnolia Heritage Construction</td>
<td>$32,456.92</td>
<td>Jul 15, 2019</td>
<td>Geralt Rivera </td>
<td class="sr-only">2165465536484</td>
</tr>
<tr>
<td colspan="6" class="collapse-data">
<div class="collapse" id="collapseOne" role="cell" aria-hidden="true">
<div class="table-expanded-data">
<h5>Supplier ID</h5>
<p>608</p>
</div>
<div class="table-expanded-data">
<h5>Ship To</h5>
<address>
Fairview Gardens<br>
567 Fairview Circle<br>
Columbia, SC 29073
</address>
</div>
<div class="table-expanded-data">
<h5>Ship To Code</h5>
<p>907</p>
</div>
</div>
</td>
</tr>
</section>