Site logo

Archived topic

Underline H2 but just the text not block?

5 replies · Started by Andy on September 20, 2022

Viewing posts 1–6 of 6

Hey folks

As per the title - I want to apply an underline effect to the H2s BUT just to the text rather than the entire block.

This is the code I'm using currently. I'm not sure what to replace the width 100% with?
appreciate your help, thanks!

ETA: I'm using border rather than text decoration as I want that curved/swoosh effect

`h2{
position: relative;
margin-right: 1rem;}
h2:after {
content: "";
position: absolute;
bottom: -10px;
left: 0;
height: 7px;
width: 100%;
border: solid 3px #D7CB83;
border-color: #D7CB83 transparent transparent transparent;
border-radius: 30%;
}

Hey Fernando :)
Thanks, see in PI field

Try adding width: fit-content to your H2.

So this code:

h2{
position: relative;
margin-right: 1rem;}

Becomes:

h2{
position: relative;
margin-right: 1rem;
width:fit-content;}

Brilliant thanks so much for the solution and also mega quick response. much appreciated:)

You're welcome Andy!

This archived topic is closed to new replies.