【发布时间】:2021-08-07 13:51:47
【问题描述】:
我正在使用 bootstrap-table,我想根据它们的值将某些列着色为红色或绿色。
我有下表:
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<link href="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
<script src="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.js"></script>
<h2>Products</h2>
<div class="table-responsive">
<table id="table" data-toggle="table" data-height="460" data-page-size="10" data-pagination="true" class="table table-striped table-hover">
<thead>
<tr>
<th data-field="trx_date" scope="col">Transaction Date</th>
<th data-field="order_type" scope="col">Buy/Sell</th>
<th data-field="total_trx" scope="col">Total Transaction</th>
<th data-field="SecInfo" scope="col">Details</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">8/18/2016</th>
<td>Sell</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Purchase</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Purchase</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Purchase</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Sell</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Sell</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Purchase</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Purchase</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Sell</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Sell</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
<tr>
<th scope="row">8/18/2016</th>
<td>Sell</td>
<td>$95,001,513.81</td>
<td><a href="">Details</a></td>
</tr>
</tbody>
</table>
</div>
有没有办法像下面这样设置每一行的样式:
我尝试在我的tr-tag 上设置data-element,但是,因为我有很多表格需要设置样式,是否有更简单的 css 方法?
感谢您的回复!
【问题讨论】:
标签: css twitter-bootstrap bootstrap-table