I have a problem where I can’t adjust it to work responsively and for different text lengths so that the line is always attached to the last word of my h2.
This is how this look on short text and how it should look like:
On mobile when text is longer its look like this:
I’m trying something like this:
h2 {
font-size: 56px;
font-weight: 700;
line-height: 67.2px;
color: #1f1f23;
text-transform: uppercase;
width: fit-content;
position: relative;
display: inline-block;
}
h2:after {
content: "";
position: absolute;
bottom: 0px;
right: -15px;
width: 50%;
height: 24px;
background-color: #ff3300;
}
<h2><span class="text relative">Newsy</span></h2>
2
Answers
A simple gradient combined with padding can do it
You can do it with javascript, this is an example (I used jquery):