I have an inner div
with max-width: 50%
. The inner div
contains content which may wrap to the next line. When the inner div
's contents wrap to the next line, due to the inner div
being > 50% the width of its parent, the div
continues to have 50% the width of its parent instead of having a width that matches its newly wrapped content.
Is there a way to have the inner div
's width shrink when the content wraps to a new line?
.outer {
background-color: red;
width: 100%;
position: relative;
}
.inner {
display: inline-block;
background: blue;
max-width: 50%;
}
<div class="outer">
<div class="inner">I_have_50%_width even_after_line_wraps</div>
</div