简体   繁体   English

锚标记中的文本超过div宽度

[英]Text in anchor tag exceeds div width

I have div tag with fixed height. 我有固定高度的div标签。 in it there is anchor tag < a> tag. 其中有锚标记<a>标记。 when text in anchor tag exceeds width of div it comes in 2 lines in div tag. 当锚标签中的文本超过div的宽度时,它在div标签中有2行。 Due height of div tag second line is displayed half. div标签第二行的正确高度显示为一半。 so how to use text-overflow :ellipsis so that ellipsis will be displayed and with which tag? 那么如何使用文本溢出:省略号以便显示省略号并使用哪个标签? please help. 请帮忙。 Thanx in advance Thanx提前

If you just need a single line of text, you can set the white-space CSS property to nowrap . 如果您只需要一行文本,则可以将white-space CSS属性设置为nowrap The complete CSS will look as follows: 完整的CSS将如下所示:

div {
    width: 75px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}​

Check this fiddle: http://jsfiddle.net/yXgQT/ 检查这个小提琴: http//jsfiddle.net/yXgQT/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM