如何在固定宽度跨度中包装或折断长文本/单词? [英] How can I wrap or break long text/word in a fixed width span?

查看:97
本文介绍了如何在固定宽度跨度中包装或折断长文本/单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个具有固定宽度的span,当我在< span> lgasdfjksdajgdsglkgsadfasdfadfasdfadsfasdfasddkgjk< / span>

I want to create a span with a fixed width that when I type any thing in the span like <span>lgasdfjksdajgdsglkgsadfasdfadfasdfadsfasdfasddkgjk</span>, a long string of non-spaced text, the word(s) break or wrap to next line.

任何想法?

推荐答案

您可以使用CSS属性 word-wrap:break-word; ,如果它们对于您的跨度太长,宽度。

You can use the CSS property word-wrap:break-word;, which will break words if they are too long for your span width.

span { 
    display:block;
    width:150px;
    word-wrap:break-word;
}

<span>VeryLongLongLongLongLongLongLongLongLongLongLongLongExample</span>

这篇关于如何在固定宽度跨度中包装或折断长文本/单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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