div&td超出部分省略号表示

前提是div宽度和table宽度固定

代码:

<style>  
div.wid{ 
    width:300px;
    white-space:nowrap;
    text-overflow:ellipsis;
    -o-text-overflow:ellipsis;
    overflow: hidden;
 }  
 .tab {
 	width : 300px;
 }
 </style>  
<div class="wid">this is a very long centence.............................................end</div>
<table border="0" style="table-layout:fixed" class="tab">
	<tr>
		<td width="100" style="overflow:hidden;text-overflow:ellipsis">this is a very long centence.............................................end
		</td>
		<td width="100" style="overflow:hidden;text-overflow:ellipsis">this is a very long centence.............................................end
		</td>
		<td width="100" style="overflow:hidden;text-overflow:ellipsis">this is a very long centence.............................................end
		</td>
	</tr>
</table>


你可能感兴趣的:(div&td超出部分省略号表示)