position absolute on heading

Hey, i have an icon to the top right of my heading placed using position absolute in this example. When the viewport shrinks, this can leave large gaps between the text and icon at some points due to the text wrapping (like in the image) and overflow too. What methods would ya'll use to make this responsive and flow smoothly with the text? https://codepen.io/deerCabin/pen/zYVqgVY Thanks in advance.
No description
7 Replies
Chooβ™šπ•‚π•šπ•Ÿπ•˜
I reduced the height of the icon because I made it stick to the last word, and that looks bad when it overlaps text on the line above. The alternative would be to increase the line height of the h1.
snxxwyy
snxxwyyβ€’2mo ago
Ah I see, that’s pretty neat, thanks for the example. did you add white-space: nowrap; so the icon doesn’t wrap to a new line?
Chooβ™šπ•‚π•šπ•Ÿπ•˜
I did that to prevent the icon from going on the next line alone. It is forced to stay with the last word.
snxxwyy
snxxwyyβ€’2mo ago
Ah that makes sense. Is there a difference between that and text-wrap: nowrap;?
Chooβ™šπ•‚π•šπ•Ÿπ•˜
The white-space is a shorthand that can include white-space-collapse with text-wrap. In this specific case, you can also use text-wrap, because no white-space-collapse was specified. The nowrap is specifically a text-wrap setting that is being declared via white-space instead.
snxxwyy
snxxwyyβ€’2mo ago
Oh I didn’t know that, thank you for the help
Want results from more Discord servers?
Add your server