---
title: "div&td超出部分省略号表示"
author: "天边一朵雲"
date: "2012-07-24T11:11:00Z"
tags: []
categories: ["Web前端"]
slug: "div-td"
draft: false
lastmod: "2012-12-24T10:39:08Z"
id: 1752789
url: "https://itexpress.iteye.com/blog/1752789"
---

前提是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>
```