I'm unable to get a div to fit the size of the text inside of it.
I have 2 divs, and I want the inner div to:
1. Fit inside the outer div.
2. Be centered inside the wrapping div.
The problem I am experiencing is that when I play around with the width of the view, I am getting a large unwanted gap between the text and the div's border, as you can see here:
How can I prevent this gap, and furthermore; how can I make the div center inside the large div to make its size big enough to fit the text inside of it?
Here is my fiddle test: https://jsfiddle.net/gv1xLd8s
My HTML code:
<div class="wrapper">
<div class="divForText">
Text... Text... Text... Text... Text... Text...
VeryLongWordToCheckTheGapProblemOnLeftAndRightSides
Text... Text...
</div>
</div>
My CSS code:
.wrapper{
border: 1px solid blue;
text-align: center;
overflow: hidden;
padding: 25px;
margin: auto;
width: 50%;
}
.divForText{
border: 1px solid black;
display: inline-block;
text-align: left;
padding: 15px;
}
Thanks!
(Note: I want to accomplish this using pure HTML and CSS)