思路:
1、box设置宽度(width)
2、设置该box的样式:
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
例如:
1、html文件中
<span>2222222222222222222222222222222222222222222222222</span>
<div>555555555555555555555555555555555555555555555555555555</div>
2、css文件中
span{ //行内元素需设置为行内块或者块级元素
display:inline-block;
width:80px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
div{//块级元素
width:80px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}