gpt4 book ai didi

html - 表格中的 Bootstrap 崩溃 - 边框和填充问题

转载 作者:太空宇宙 更新时间:2023-11-04 05:47:50 25 4
gpt4 key购买 nike

我有一张 table ,里面有另一张 table 。这有一个 div 和来自 bootstrap 的折叠类。所以我可以用第一行的按钮折叠它。

问题如下:

  1. 我只想要红色边框,当它处于事件状态时。黑色的应该消失。不用js可以吗?

  2. 我是否需要自己调整 padding,让每个单元格都在彼此之间?或者有其他解决方案吗?

  3. 你会这样做吗?

我尝试过其他一些解决方案,例如更改 div 的位置或不使用 td,但大多数情况下,折叠之后会被破坏。

enter image description here

table {
width: 800px;
}

tr {
background-color: darkgray;
}

td {
padding:10px;
}

.tr-info {
border-bottom: 1px solid black;
}

.mybutton {
width: 10%;
height: 10%;
font-size: 2px;
}

.hiddenRow {
padding: 0;
}

.hiddenRow th {
border-top: 1px solid red;
}
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Your Website</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />


</head>

<body style="background: light-grey;">

<div class="container mt-5">

<div class="row">
<div class="col-12">
<table>
<tbody>
<tr class="tr-info">
<td>
som1
</td>
<td>
some2
</td>
<td>
<button class="mybutton" type="button" data-toggle="collapse" data-target="#dodo" aria-expanded="false" aria-controls="collapseExample">
Button with data-target
</button>
</td>
</tr>
<tr>
<td colspan="3" class="hiddenRow">
<div class="collapse" id="dodo">
<table>
<thead>
<tr class="tr-info">
<th>dodo</th>
<th>dodo2</th>
<th>status</th>
</tr>
</thead>
<tbody>
<tr class="tr-info">
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>

</td>

</tr>
<tr class="tr-info">
<td>dodo</td>
<td>d</td>
<td>d</td>
</tr>
</tbody>
</table>
</div>
</div>


</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="script.js"></script>
</body>

</html>

最佳答案

设置

td ,th{
min-width: 110px;
padding:10px;
}

用于对齐表格

边框

div#dodo {
margin-top: -1px;
z-index: 111;
position: relative;
}

关于html - 表格中的 Bootstrap 崩溃 - 边框和填充问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58556026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com