HTML是否支持剪裁标签的宽度?

时间:2011-04-27 09:51:49

标签: html

HTML中是否有标签具有特定宽度的功能,当需要在其给定宽度上呈现时,它应该剪切并显示...。在工具提示中,显示完整的实际名称。

这样的事情:

enter image description here

2 个答案:

答案 0 :(得分:3)

尝试text-overflow:ellipsisoverflow:hidden CSS样式。它们必须一起使用,否则文本溢出将被忽略。

所有浏览器(尤其是IE)可能都不支持文本溢出,因此您的测试也很好。

答案 1 :(得分:0)

http://jsfiddle.net/jwB2Y/123/

剪辑标签文本的一个选项是设置max-width属性以及overflow和white-space属性。要显示...,您需要使用文本溢出:省略号。

.inline-label { 
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    float:left;     
    }

<div>
    <label for="id1" class="inline-label">This is the dummy text i want to display::</label>
    <input type="text" id="id1"/>
</div>