CSS - 最大宽度和省略号 [英] CSS - Max Width and Ellipses

查看:212
本文介绍了CSS - 最大宽度和省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含文本的span。我想要跨度扩展到最大500px,以容纳里面的文本。在达到最大值后,我想要文本显示省略号任何溢出max-width的文本。这可能吗?



  {
position:absolute;
top:13px;
left:44px;
max-width:500px;
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
}


解决方案

这是一篇有趣的文章,关于在不使用javascript的情况下,在所有现代浏览器上使用省略号。


I have a span that will contain text. I would like the span to expand to a maximum of 500px to accommodate the text inside. After the max is reached I would like the text to display ellipses for any text overflowing the max-width. Is this possible? I tried the following, but this did not do the trick.

Thanks

{
    position: absolute;
    top: 13px;
    left: 44px;
    max-width: 500px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}

解决方案

This is an interesting article about getting ellipsis to work on all modern browsers without using javascript.

这篇关于CSS - 最大宽度和省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆