table 设置 style=”table-layout: fixed”
并且在 td标签中使用
style= “white-space:nowrapoverflow:hiddentext-overflow: ellipsis”
其他标签
你试试 加入样式
width:150pxwhite-space:nowraptext-overflow:ellipsisoverflow: hidden
用php或者其他的截取吧,css好像只可以隐藏多余的
function
msubstr($str,$start,$len){
for($i=0$i<$start+$len$i++){
$tmpstr=(ord($str[$i])>=161
&&
ord($str[$i])<=247&&
ord($str[$i+1])>=161
&&
ord($str[$i+1])<=254)?$str[$i].$str[++$i]:$tmpstr=$str[$i]
if
($i>=$start&&$i<($start+$len))$tmp
.=$tmpstr
}
return
$tmp
}
这个是php截取类
.text-overflow {
display:block/*内联对象需加*/
width:31em
word-break:keep-all/* 不换行 */
white-space:nowrap/* 不换行 */
overflow:hidden/* 内容超出宽度时隐藏超出部分的内容 */
text-overflow:ellipsis/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden一起使用。*/
}
扩展资料:上面是不带省略号,反之显示省略号
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
margin: 0px
padding: 0px
}
#div1 {
width: 300px
height: 300px
background: red
}
.pText {
display: block
height: 30px
width: 250px
text-overflow: ellipsis
overflow: hidden
white-space: nowrap
}
.aText {
width: 100px
white-space: nowrap
}
</style>
</head>
<body>
<div id="div1">
<span>
<a>空白会被浏览器保留。其行为方式类似 HTML 中的标签。</a>
</span>
</div>
</body>
</html>
多行文本可以使用如下样式:
.intwoline {
display: -webkit-box !important
overflow: hidden
text-overflow: ellipsis
word-break: break-all
-webkit-box-orient: vertical
-webkit-line-clamp: 3
}