HTML带有虚线结尾的大文本 [英] HTML Large text with dotted end

查看:111
本文介绍了HTML带有虚线结尾的大文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在固定大小的div中显示文字,如果文字的大小大于多个文字,应以小点表示。

I want to display text inside a fixed size div if the size of text is large than more text should be indicated with dots.

示例

如果在div中显示的文本数量为10,则

if number of text can be displayed inside div is 10 then

文本澳大利亚应显示为澳大利亚 $ b textUnited States Of America应显示为United Sta ...

text "Australia" should be displayed like "Australia" text "United States Of America" should be displayed like "United Sta..."

推荐答案

您正在寻找:

text-overflow: ellipsis;

例如:

<div style="width: 5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
    United States of America
</div>

将显示


United St ...

United St...

文本必须在一行中(因此 :nowrap ),并溢出一个框,其中溢出被隐藏(因此 overflow:hidden )。提供这里

The text must be in one line (hence the white-space: nowrap), and overflow a box where the overflow is hidden (hence the overflow: hidden). Fiddle available here.

这篇关于HTML带有虚线结尾的大文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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