gpt4 book ai didi

html - 智能 HTML 表格列宽

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

这是我的 table 目前的样子:

enter image description here

我想缩小两个按钮之间的距离,让按钮更靠近文本内容。但是,如果我输入一些非常长的文本,或者在大/小屏幕上查看它,我仍然希望表格能够调整。

jsFiddle link

这是我当前的 HTML:

<table cellspacing="0" rules="all" border="1" style="border-collapse:collapse;">
<thead>
<tr>
<th scope="col">Manufacturer</th>
<th scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td class="fullWidth">Arrow International</td>
<td class="fixedWidth"><input type="button" value="Report" class="button" /></td>
<td class="fixedWidth"><input type="button" value="Delete" class="button" /></td>
</tr>
<tr>
<td class="fullWidth">Cardinal Health</td>
<td class="fixedWidth"><input type="button" value="Report" class="button" /></td>
<td class="fixedWidth"><input type="button" value="Delete" class="button" /></td>
</tr>
<tr>
<td class="fullWidth">DeRoyal</td>
<td class="fixedWidth"><input type="button" value="Report" class="button" /></td>
<td class="fixedWidth"><input type="button" value="Delete" class="button" /></td>
</tr>
<tr>
<td class="fullWidth">Kimberly-Clark</td>
<td class="fixedWidth"><input type="button" value="Report" class="button" /></td>
<td class="fixedWidth"><input type="button" value="Delete" class="button" /></td>
</tr>
</tbody>

这是我当前的 CSS:

#main-content table {
width: 100%;
border-collapse: collapse;
}

#main-content table thead th {
font-weight: bold;
font-size: 15px;
border-bottom: 1px solid #ddd;
}

#main-content tbody {
border-bottom: 1px solid #ddd;
}

#main-content tbody tr {
background: #fff;
}

#main-content tbody tr.alt-row {
background: #f3f3f3;
}

#main-content table td,
#main-content table th {
padding: 10px;
line-height: 1.3em;
}

#main-content table tfoot td .bulk-actions {
padding: 15px 0 5px 0;
}

#main-content table tfoot td .bulk-actions select {
padding: 4px;
border: 1px solid #ccc;
}

#main-content td .fixedWidth {
white-space: nowrap;
width: 0%;
}

#main-content td .fullWidth {
width: 100%;
white-space: normal;
}

我一直在试验 white-space: nowrap 但还没有找到解决方案!

我接近了吗?

最佳答案

你的表格总是调整到 100%,在 CSS 中改变它:

#main-content table {
/*width: 100%;*/
border-collapse: collapse;
}

这将使表格根据内容宽度进行调整。

关于html - 智能 HTML 表格列宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9057912/

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