Reputation: 71
I'm trying to create a div for text that resizes the width depending on how much text is in the div, but also has a maximum width, thus splitting the text into multiple lines if it exceeds the max-width. The text does resize with one line of text and split when there's too much, but when there's more than one line a large space appears inside the div between the right edge of the text and the border.
HTML:
<div class="balloon">
This is sample text. This is a second sentence.
</div>
CSS:
.balloon {
background: #FFF;
border: solid 2px;
display: inline-block;
max-width: 225px;
}
Here's a demo to demonstrate what I mean: http://jsfiddle.net/oft3n5wg/
Any ideas about how to fix this?
Upvotes: 2
Views: 358
Reputation: 142
Your content goes in here
The whole idea is specifying a max-width and also sett
Upvotes: 0
Reputation: 10021
This is just because the first word on the 2nd line is too large to fit in that space your have highlighted in red. Replace the word "second" with "seco" and you'll see that it fits
you can add a text-align: center
so that the space doesn't look as bad if you want, or do letter-spacing: 1px
so there's more space between the letters and it will fill the white spaces a bit more
Upvotes: 1