In my collection of div rows with variable width inside a resizable container, I'm encountering an issue with a hanging indent. The problem arises when the width is too low, causing the first line to be pushed beneath the red label.
At 450px, everything displays correctly in .wrapper
, but at 250px you can see the layout breaking. My goal is to always keep the longtextthatwraps
span on the same line as the red label.
Check out this live example/fiddle and take a look at the source below:
HMTL (note: there is no whitespace between .prefix
and .part
for readability...):
<div class="wrapper">
<div class="padded excludes">
<div class="parts first">
<span class="prefix">Quisques: </span>
<span class="segment level-0">
<span class="part text">longtextthatwraps incorrectly (<a href="#" class="code">0000</a>-<a href="#" class="code">0000</a>)</span>
</span>
</div>
<div class="parts">
<span class="segment level-0">
<span class="part text">consectetur adipiscing (<a href="#" class="code">0000</a>-<a href="#" class="code">0000</a>)</span>
</span>
</div>
<div class="parts">
<span class="segment level-0">
<span class="part text">quisque non mauris sed:</span>
</span>
</div>
<div class="parts">
<span class="segment level-1">
<span class="part list-item">hendrerit (<a href="#" class="code">0000</a>-<a href="#" class="code">0000</a>)</span>
</span>
</div>
<div class="parts">
<span class="segment level-1">
<span class="part list-item">non mauris sed (<a href="#" class="code">0000</a>-<a href="#" class="code">0000</a>)</span>
</span>
</div>
<div class="parts">
<span class="segment level-1">
<span class="part list-item">lorem ipsum dolor (<a href="#" class="code">0000</a>-<a href="#" class="code">0000</a>)</span>
</span>
</div>
</div>
</div>
CSS:
.wrapper {
width: 250px;
background: #c3dff5;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
}
.padded {
padding-left: 20px;
}
.parts {
padding-left: 80px;
}
.parts.first {
padding-left: 0;
}
.prefix {
color: #D12;
font-weight: bold;
min-width: 80px;
display: inline-block;
}
.level-0,.level-1 {
display: inline-block;
padding-left: 5px;
text-indent: -5px;
outline: 1px dotted #f0f;
}
.level-1 {
padding-left: 20px;
}
Your help would be greatly appreciated. Thank you!