我有一张桌子,在每一列和每一行中,都有一个包含多个项目的列表组。
我想将列宽和所有其他列表组的宽度动态调整为列表组中最大元素的大小。例如,这是最后一个“ toasterfürtoastbrot”项目。
除此之外,即使我使用顶部的按钮隐藏了一些元素,我也希望保持该宽度。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<script>
$(document).ready(function () {
$('#toggle-buttons label').click(function () {
$('.list-group-item-' + $(this).attr('toggle')).toggle();
});
});
</script>
<style>
li {
line-height: 0;
}
</style>
</head>
<body>
<div class="container">
<h2 style="display: inline-block;">toaster</h2>
<div id="toggle-buttons" class="btn-group-toggle float-right" data-toggle="buttons">
<label class="btn btn-outline-success active" toggle="success">
<input type="checkbox" checked autocomplete="off"> NEW
</label>
<label class="btn btn-outline-danger active" toggle="danger">
<input type="checkbox" checked autocomplete="off"> DEL
</label>
<label class="btn btn-outline-warning active" toggle="warning">
<input type="checkbox" checked autocomplete="off"> CHANGE
</label>
<label class="btn btn-outline-secondary active" toggle="secondary">
<input type="checkbox" checked autocomplete="off"> SAME
</label>
</div>
<table class="table">
<thead>
<tr>
<th>Index</th>
<th>Rev #1</th>
<th>no newer Rev</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>
<ul class="list-group">
<li class="list-group-item list-group-item-warning">
<span class="badge">3</span>
toaster edelstahl
<span class="badge float-right badge-success badge-pill">+3</span>
</li>
<li class="list-group-item list-group-item-success">
<span class="badge">4</span>
toaster 4er
<span class="badge float-right badge-secondary badge-pill">NEW</span>
</li>
<li class="list-group-item list-group-item-warning">
<span class="badge">9</span>
toaster rot
<span class="badge float-right badge-danger badge-pill">-4</span>
</li>
<li class="list-group-item list-group-item-danger">
<span class="badge">X</span>
toaster einhand
<span class="badge float-right badge-secondary badge-pill">DEL</span>
</li>
</ul>
</td>
<td>-</td>
</tr>
<tr>
<td>a (qs)</td>
<td>
<ul class="list-group">
<li class="list-group-item list-group-item-secondary">
<span class="badge">1</span>
toaster wasweißich
</li>
<li class="list-group-item list-group-item-secondary">
<span class="badge">2</span>
toaster hype
</li>
<li class="list-group-item list-group-item-warning">
<span class="badge">3</span>
toaster edelstahl
<span class="badge float-right badge-success badge-pill">+3</span>
</li>
<li class="list-group-item list-group-item-success">
<span class="badge">4</span>
toaster 4er
<span class="badge float-right badge-primary badge-pill">NEW</span>
</li>
<li class="list-group-item list-group-item-secondary">
<span class="badge">5</span>
toaster noname
</li>
<li class="list-group-item list-group-item-secondary">
<span class="badge">6</span>
toaster ok
</li>
<li class="list-group-item list-group-item-danger">
<span class="badge">X</span>
toaster einhand
<span class="badge float-right badge-primary badge-pill">DEL</span>
</li>
<li class="list-group-item list-group-item-secondary">
<span class="badge">7</span>
toaster mini
</li>
<li class="list-group-item list-group-item-secondary">
<span class="badge">8</span>
toaster toast
</li>
<li class="list-group-item list-group-item-warning">
<span class="badge">9</span>
toaster rot
<span class="badge float-right badge-danger badge-pill">-4</span>
</li>
<li class="list-group-item list-group-item-success">
<span class="badge">10</span>
toaster für toastbrot
<span class="badge float-right badge-primary badge-pill">NEW</span>
</li>
</ul>
</td>
<td>-</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>