For example, If I have a sentence like the following:
I like cute dogs because they're awesome
doing something like word-break: break-word might give you
I like cute dogs because they're awe
some
The behavior I want is for it to break like
I like cute dogs because they're
awesome
I can't seem to find a way to do this. In most cases, the words do seem to fit efficiently into the container, but there are weird cases with long words that spill out even though I would think it should know how to rearrange them for this not to happen. The words aren't even close in length to the width of the container, so it's not that what I'm trying to achieve is impossible or anything. The CSS I have written is so negligible that it's probably not even worth including, but it's something like:
.someClass {
margin-bottom: 2rem;
padding: 0.5rem;
}
p {
font-size: 1.1rem;
margin-bottom: 0.375rem;
}
.someClass' size is a fixed value, and its parent is a flex container. I tried adjusting the available space of the flex cell it occupies to exactly the size of the container element but it made no difference.
- Why do words which are only a fraction of the width of the parent overflow sometimes? Like, why aren't they auto arranged to divide the space without overflowing?
- Is there a way to ensure no overflow but without breaking mid-word, and instead of breaking at word boundaries?
Thanks for the help and cheers.