I\'ve got an absolutely positioned div I\'m working with, and I put some text inside of it just to be able to find it on the page, namely:
I solved this by adding a wrapper div that is also absolutely positioned, with the width I want my div to expand up to.
E.g.,
And css,
.wrapper {
position: absolute;
width: 500px;
}
.my-div {
position: absolute;
whitespace: pre-wrap;
}
You can add whitespace: pre-wrap to allow wrapping lines, which makes this more flexible than the nowrap solution.