0

给定以下 html 表,我想通过设置“col”元素的宽度而不是在 div 元素上设置它来控制第一列的宽度,而不会丢失省略号。仅使用 html 和 CSS 有可能吗?

<html>
<head>
<style>
.hideextra { white-space: nowrap; overflow: hidden; text-overflow:ellipsis; }
</style>
</head>
<body>
<table style="width: 300px">
<col /><!-- ** set width here ** -->
<tr>
    <td>Column 1</td><td>Column 2</td>
</tr>
<tr>
   <td>
    <div class="hideextra" style="width:200px">
                this is the text in column one which wraps</div></td>
   <td>
        <div class="hideextra" style="width:100px">
                this is the column two test</div></td>
</tr>
</table>
</body>
</html>
4

1 回答 1

0

可以这样做:

<table border="1" width="100%" style="table-layout: fixed; ">
<col width="60px">
<tr>
    <td style="overflow: hidden;text-overflow: ellipsis;">500.000.000.000.000</td>
    <td>10.000</td>
</tr>
<tr>
    <td>1.500.000</td>
    <td>2.000</td>
</tr>
</table>
于 2012-06-26T08:17:39.470 回答