Html 使内容适合 div 的宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17994392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Make content fit to the width of the div
提问by VeNaToR
How can I make a text fit to the width of div. Here is my code
如何使文本适合 div 的宽度。这是我的代码
<div class="column">
<a href="#" class="user_thumbnail">
<img src="<?=base_url()?>/images/1.jpg" width="100px" height="100px">
</a>
<span class="name">texttexttexttexttexttexttexttexttexttext</span>
</div>
When I have tried to display the text, the text overflows out of the div like a straight line.
How can i do css to fit the text to the width of <div class="column">
(width = 33%).
当我试图显示文本时,文本像一条直线一样从 div 中溢出。我如何做 css 以适应文本的宽度<div class="column">
(宽度 = 33%)。
回答by Praveen
回答by adrift
You can use word-break: break-all;
(assuming you meant fit the widthof the div, not the height like your title says)
您可以使用word-break: break-all;
(假设您的意思是适合div的宽度,而不是您标题所说的高度)
.column {
width: 33%;
word-break: break-all;
}