2012-06-25 1 views
0

Учитывая следующую таблицу html, я хотел бы контролировать ширину первого столбца, установив ширину элемента 'col' вместо того, чтобы устанавливать его на div элемент, не теряя многоточия. Возможно ли это, используя только html и CSS?Как управлять шириной столбца таблицы html в сочетании с переполнением текста

<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> 

ответ

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> 
Смежные вопросы