Hai*_*ien 1 html javascript css jquery
我有HTML像:
<div class="box">
<a href="#">Stackoverflow is very useful site and I love it</a>
</div>
Run Code Online (Sandbox Code Playgroud)
和CSS一样:
.box {
width:230px;
height:50px;
line-height:50px;
background:#eee;
}
.box a {
color:#000;
}
Run Code Online (Sandbox Code Playgroud)
我想创建缩短链接的文本.如果它本身溢出了box课程,那就把它带到"......".我怎么能用css或jquery做到这一点?
在这里检查jsfiddle
将以下样式添加到.box:
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
Run Code Online (Sandbox Code Playgroud)
工作样本:http://jsfiddle.net/qLzK7/