我想知道是否可以根据下面标签的宽度来确定标签的宽度。
我目前有这张表:
<table>
<tr>
<td>This title is way too long and screws up my style</td>
<td>Title2</td>
<td>Title 3</td>
</tr>
<tr>
<td><img src="http://domain.com/image1.jpg" /></td>
<td><img src="http://domain.com/image2.jpg" /></td>
<td><img src="http://domain.com/image3.jpg" /></td>
</tr>
</table>
有没有根据下面图片的宽度来缩放 Title 标签?
希望它是清楚的。
最佳答案
这可能被认为有点 hack,但如果您将上一行中的单元格宽度设置为具有可接受的最小值,则第二行中的单元格将扩展列。这是一个示例:
<style>
tr.titles td {
width: 1px;
}
</style>
<table>
<tr class="titles">
<td>This title is way too long and screws up my style</td>
</tr>
<tr>
<td><img src="http://domain.com/image2"/></td>
</tr>
</table>
所以在这种情况下,图像将决定列的宽度,总宽度将等于图像宽度。
关于html - 根据下面的宽度 <td> 确定 <td> 的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15094050/