I’ve this style for my titles on my website:
.heading-text>* {
position: relative;
}
.heading-text h4 {
font-size: 34px;
margin-bottom: 30px;
letter-spacing: -.7px;
line-height: 40px;
}
.heading-text.heading-line h4:before {
content: '';
position: absolute;
width: 100%;
height: 15px;
bottom: 5px;
background-color: #fcf8e3;
z-index: -1
}
<div class="heading-text heading-line">
<h4>
My super loooong title
</h4>
</div>
<div class="heading-text heading-line">
<h4>
My short title
</h4>
</div>
The issue I’m facing is the yellow bar is not fitting the text width.
Is there a way it can be adjust automatically ?
Thanks.
>Solution :
You could make the h4 not take the whole screen, by using display:inline-block;
.heading-text>* {
position: relative;
display:inline-block;
}