我想在链接上使用文本溢出属性.我为一个段落工作但不是为了一个链接.
这是HTML代码
<div>
<ul>
<li>
<p>the text is too long</p>
</li>
<li>
<a href="javascript:alert('test')">the link is too long</a>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
这是css代码:
a {
white-space: nowrap;
width:50px;
overflow: hidden;
text-overflow: ellipsis;
}
p {
white-space: nowrap;
width:50px;
overflow: hidden;
text-overflow: ellipsis;
}
Run Code Online (Sandbox Code Playgroud)
请参阅http://jsfiddle.net/corinnekm/LLVDB/上的示例
非常感谢你的帮助.
小智 7
http://primercss.io/utilities/有一套css截断规则.见https://jsfiddle.net/illegs/g04L9xd6/
.css-truncate.css-truncate-target,
.css-truncate .css-truncate-target {
display: inline-block;
max-width: 50px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: top
}
.css-truncate.expandable.css-truncate-target,
.css-truncate.expandable.css-truncate-target,
.css-truncate.expandable:hover .css-truncate-target,
.css-truncate.expandable:hover.css-truncate-target {
max-width: 10000px !important
}
<span class="css-truncate expandable">
<span class="branch-ref css-truncate-target"><a href="javascript:alert('test')">the link is too long</a></span>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
28289 次 |
最近记录: |