gpt4 book ai didi

html - 摆脱表格中的填充

转载 作者:太空宇宙 更新时间:2023-11-03 21:10:10 25 4
gpt4 key购买 nike

我有一个表格,我希望它的标题包含所有 5 列。确实如此,但标题和表格边框之间有一点填充,我无法摆脱它。我需要标题来占据表格的整个宽度。有什么建议吗?

.foo {
min-width: 250px;
width: auto;
text-align: center;
min-height: 30px;
border: 1px solid #515151;
border-radius: 6px;
position: absolute;
padding: 0;
background: url(images/comment-bg3.png) repeat;
overflow: hidden;
text-shadow: 1px 1px 1px rgba(0,0,0,0.33);
box-shadow: 5px 5px rgba(0,0,0, 0.1);
}

.thClass {
margin-left: -3px;
text-align: center;
background: url(images/comment-bg2.png) repeat;
box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
margin-top: -2px;
min-height: 30px;
line-height: 30px;
font-size: 19px;
cursor: move;
}

.header{
margin-left: 17px;
}

.tableBody {
display: block;
min-height: 25px;
text-align: center;
width: 102%;
margin-left: -2px;
cursor: default;
}

.foo tbody tr td {
display: block;
line-height: 25px;
text-align: center;
border-bottom: 1px solid rgba(0,0,0,0.2);
}

#displaySizes {
list-style: none;
padding: 0;
margin-top: 0;
}

.disp tbody tr th {
column-span: all;
border: 1px solid black;
}

.disp tbody tr td {
display: table-cell;
}
<table class="foo disp elementTable">
<tr class="tableHeader">
<th class="thClass" colspan="5">
<span class="header">Device</span>
<span class="settings">
<img src="Icons/pignon.png" width="17px" height="17px" alt="Settings" title="Settings" />
</span>
</th>
</tr>
<tr>
<td rowspan="4" id="sizeContainer">
<ul id="displaySizes">
<li>4:3</li>
<li>16:9</li>
<li>Clock</li>
</ul>
</td>
<td>$100</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
</table>

实现此目的的一种方法是设置标题 display:block; 然后使其成为 width:102%;,但在这种情况下 colspan="5" 不起作用。这是一个 fiddle 供您玩代码:https://jsfiddle.net/vaxobasilidze/b996809u/

最佳答案

使用 border-spacing 属性。在下面的代码片段中,我使用了 0px。浏览器默认使用 2px

.foo {
min-width: 250px;
width: auto;
text-align: center;
min-height: 30px;
border: 1px solid #515151;
border-radius: 6px;
position: absolute;
padding: 0;
background: url(images/comment-bg3.png) repeat;
overflow: hidden;
text-shadow: 1px 1px 1px rgba(0,0,0,0.33);
box-shadow: 5px 5px rgba(0,0,0, 0.1);
border-spacing: 0px;
}

.thClass {
margin-left: -3px;
text-align: center;
background: url(images/comment-bg2.png) repeat;
box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.26);
margin-top: -2px;
min-height: 30px;
line-height: 30px;
font-size: 19px;
cursor: move;
padding:0;
}

.header{
margin-left: 17px;
}

.tableBody {
display: block;
min-height: 25px;
text-align: center;
width: 102%;
margin-left: -2px;
cursor: default;
}

.foo tbody tr td {
display: block;
line-height: 25px;
text-align: center;
border-bottom: 1px solid rgba(0,0,0,0.2);
}

#displaySizes {
list-style: none;
padding: 0;
margin-top: 0;
}

.disp tbody tr th {
column-span: all;
border: 1px solid black;
}

.disp tbody tr td {
display: table-cell;
}
<table class="foo disp elementTable">
<tr class="tableHeader">
<th class="thClass" colspan="5">
<span class="header">Device</span>
<span class="settings">
<img src="Icons/pignon.png" width="17px" height="17px" alt="Settings" title="Settings" />
</span>
</th>
</tr>
<tr>
<td rowspan="4" id="sizeContainer">
<ul id="displaySizes">
<li>4:3</li>
<li>16:9</li>
<li>Clock</li>
</ul>
</td>
<td>$100</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
<tr>
<td>February</td>
<td>February</td>
<td>February</td>
<td>February</td>
</tr>
</table>

关于html - 摆脱表格中的填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47752871/

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