2012-06-25 2 views
0

다음 html 테이블에서 div의 값을 설정하는 대신 'col'요소의 너비를 설정하여 첫 번째 열의 너비를 제어하고 싶습니다. 엘리먼트, 생략 부호를 잃지 않고. 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> 
관련 문제