- #1
Darkmisc
- 225
- 31
- TL;DR Summary
- I have a heading with an underline that lines up perfectly so long as the heading occupies only one line. However, when I change the screen width, the heading spreads across two lines. When this happens, the space before the lines of text gets extended and this affects where the underline starts.
I have a heading with an underline that lines up perfectly so long as the heading occupies only one line.
However, when I change the screen width, the heading spreads across two lines. When this happens, the space before the lines of text gets extended and this affects where the underline starts.
This is the code for the heading and underline:
width: min-content sort of works, but it makes my heading always take up four lines. I'd like it to always take up the minimum lines possible.
I could use media queries to push the underline further right, but I'd prefer to control the amount of space in front of the lines of text. Is there a way to do this?
Thanks
However, when I change the screen width, the heading spreads across two lines. When this happens, the space before the lines of text gets extended and this affects where the underline starts.
This is the code for the heading and underline:
Heading/Underline:
const ParaText = styled.h2.attrs({
className: "color1 Font SectionHeading",
})`
font-family: roboto;
display: inline-block;
font-weight: 600;
width:max-content;
text-align: center;
background:pink;
position: relative;
padding-left:0;
&::after {
content: '';
position: absolute;
bottom: -5px;
left: 0;
width: 50%;
height: 2px;
background-color: currentColor;
}
`;
width: min-content sort of works, but it makes my heading always take up four lines. I'd like it to always take up the minimum lines possible.
I could use media queries to push the underline further right, but I'd prefer to control the amount of space in front of the lines of text. Is there a way to do this?
Thanks