Created
June 19, 2014 07:56
-
-
Save ourai/b0a639f1f6a6f3659b2b to your computer and use it in GitHub Desktop.
IE8 中会出现即使文本被省略也会占用空间的情况,目前所知道的解决方案就是对父级也设置 `max-width`。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>文本省略</title> | |
<style> | |
a, | |
span { | |
display: inline-block; | |
*display: inline; | |
vertical-align: middle; | |
zoom: 1; | |
} | |
a { | |
background-color: orange; | |
} | |
span { | |
background-color: yellow; | |
} | |
.te a { | |
overflow: hidden; | |
} | |
.te span { | |
max-width: 150px; | |
white-space: nowrap; | |
overflow-x: hidden; | |
text-overflow: ellipsis; | |
} | |
</style> | |
</head> | |
<body> | |
<div> | |
<h3>完整文本</h3> | |
<a href="javascript:void(0);"><span>一个目前人在杭州,主要从事 web 前端开发的 web developer。</span></a> | |
</div> | |
<div class="te"> | |
<h3>省略文本</h3> | |
<a href="javascript:void(0);"><span>一个目前人在杭州,主要从事 web 前端开发的 web developer。</span></a> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment