开发者

How can I get a long text fit in a smaller DIV, wrapping itself in a new line if necessary?

开发者 https://www.devze.com 2023-01-27 05:47 出处:网络
I can make the text fit inside the div? <div> Hello! This a long text, but I\'d like it to fit the div\'s width

I can make the text fit inside the div?

<div>
 Hello! This a long text, but I'd like it to fit the div's width
</div>

So far, I'开发者_如何学编程ve used max-width:100px, expecting the text to be wrapped to a new line. But, what I've gotten so far is a long text appearing above its containet and overfilling other containers.

It's looks like, just using max-width, is not enough.

Thanks for helping


If you're using &nbsp; characters instead of spaces, the line will overflow.

Also, check if the white-space attribute is set to "normal" and not "nowrap".


width:100px; should do it, depending on what other properties are set on the div.

0

精彩评论

暂无评论...
验证码 换一张
取 消