How can I make a text fit to the width of div. Here is my code
<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%).
There are three ways to solve this problem which are listed below: By default case. Using inline-block property. Using fit-content property in width and height.
For width it's easy, simply remove the width: 100% rule. By default, the div will stretch to fit the parent container.
In a few words width: fit-content; means : "Use the space you can (available) but never less than your min-content and never more than your max-content "
word-wrap:break-word
So try the below CSS
.column {
width: 33%;
word-wrap: break-word;
}
JSFiddle
You can use word-break: break-all;
(assuming you meant fit the width of the div, not the height like your title says)
.column {
width: 33%;
word-break: break-all;
}
http://jsfiddle.net/VbTes/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With