---
title: "css实现在文本溢出时，显示省略标记（...）"
author: "keimon"
date: "2013-08-05T14:58:08Z"
tags: []
categories: ["Web前端"]
slug: "css"
draft: false
lastmod: "2013-09-22T11:33:50Z"
id: 1920223
url: "https://keimon.iteye.com/blog/1920223"
---

**属性：**强制换行：

`word-wrap:break-word; word-break:break-all; white-space:pre-wrap;`  
　　　 强制不换行：

`overflow:hidden; width:300px; white-space:nowrap; text-overflow: ellipsis;`

&lt;style&gt;  
\* { margin: 0; padding: 0; }  
a { text-decoration: none; color: #000; }  
ul {  
    width: 300px;  
    margin: 40px auto;  
    padding: 12px 4px 12px 24px;  
    border: 1px solid #D4D4D4;  
    background: #F1F1F1;  
    list-style: none;  
}  
li { margin: 12px 0; }  
li a {  
    display: block;  
    width: 80px;  
    overflow: hidden;/\*注意不要写在最后了\*/  
    white-space: nowrap;  
    -o-text-overflow: ellipsis;  
    text-overflow: ellipsis;    
}  
/*  
clip：  
    不显示省略标记（...），而是简单的裁切。  
ellipsis：  
    当对象内文本溢出时显示省略标记（...）  
\*/  
&lt;/style&gt;  
&lt;/head&gt;  
&lt;body&gt;  
&lt;ul&gt;  
   &lt;li&gt;&lt;a href="#"&gt;网页设计网页设计网页设计&lt;/a&gt;&lt;/li&gt;  
&lt;/ul&gt;