So I have a simple div in which I have a p with some text. I want the text to stay inside the div, and that is going good so far, but when I resize the window of my browser horizontal, the text inside the div is flowing out of the div on the bottom.
#textbox {
position: absolute;
left: 180px;
top: 420px;
height: 250px;
width: 20%;
background-color: white;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
#text {
text-align: center;
font-family: 'Roboto', sans-serif;
font-style: italic;
font-size: 20px;
word-wrap: break-word;
}
<div id="textbox">
<p id="text">Here is some example text that is about the same amount as I really have here, but I don't want to reveal what.</p>
</div>
According to the answers on similar questions, I have to add word-wrap: break-word; which I already have.
If this helps, the text is not flowing out at left or right, it flows out at the bottom.
So my question, what do I do, to keep the text inside the div when I'm moving the browser window?
Just replace height: 250px to min-height: 250px;
#textbox {
position: absolute;
left: 180px;
top: 420px;
min-height: 250px;
width: 20%;
background-color: white;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
#text {
text-align: center;
font-family: 'Roboto', sans-serif;
font-style: italic;
font-size: 20px;
word-wrap: break-word;
}
<div id="textbox">
<p id="text">Here is some example text that is about the same amount as I really have here, but I don't want to reveal what.</p>
</div>
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