I have headings that have display:inline-block
set, but one of them is really long and takes two lines. The issue is that when it breaks to the second line, it automatically makes it take the whole width of the parent container (even though it has plenty of space around it, and it is set to inline-block).
Anyone knows how to prevent this? Also, I can't really use a solution that only applies to this one if it will break other headings, because the same code is generating other 9 non-line-breaking headings using the same structure.
Thank you for your time.
CodePen: https://codepen.io/anon/pen/gGdYmB#anon-signup
<div id="parent1" class="parent">
<h2>SHORT HEADING</h2>
<h2>THE REALLY LONG HEADING THAT
<span>BREAKS TO A SECOND LINE</span></h2>
</div>
<style>
.parent {
width:50vw;
background-color:#046;
height:20vw;
text-align:center;
}
.parent h2 {
display:inline-block;
color:#fff;
font-family:sans-serif;
font-weight:900;
font-size:2vw;
background-color:#28a;
padding:10px 0;
}
.parent h2 span {
display:inline-block
}
</style>
tag .... – lalit bhakuni Oct 13 '17 at 06:51
would make it break on every single device, not just the ones with smaller or larger screens. I could remove it selectively with jQuery, but I am ideally looking for an html/css only solution. – cVergel Oct 13 '17 at 16:30
instead of wrapping the second line in a ? I was trying to avoid
on purpose, but it seems to be the solution. – cVergel Oct 13 '17 at 16:37