.box {
width: 230px;
border: 1px solid black;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
svg {
/* The size of the icon can vary */
width: 24px;
height: 24px;
}
<div class="box">
<span class="text truncate">
This is some example content
<svg width="48" height="48" viewBox="0 0 48 48">
<path id="icon-info" d="M22 34h4V22h-4v12zm2-30C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16zm-2-22h4v-4h-4v4z">
</path>
</svg>
while maintaining truncation at the end
</span>
</div>
This instance presents Text paired with an SVG element. The SVG has specific dimensions, but these may change dynamically.
Is there a method to consistently align the SVG in the center irrespective of its dimensions without disrupting the truncation effect? (Applying display: flex interferes with the ellipsis).
I have tested the technique outlined in the aforementioned blog post, which necessitates assigning the SVG a height and width of 1em. If I increase this size, I am uncertain how to calculate the top value dynamically.