I am attempting to position an HTML element beside the first line of a heading. To clarify, I have taken screenshots to illustrate the current appearance and desired outcome.
Current Appearance:
Desired Outcome:
In order to change the background of the title's first line to red, I utilized the ::first-line
pseudo-selector.
So far, my attempts to add a text content in the ::after
of the ::first-line
have been unsuccessful due to limitations on adding html content to both ::before
and ::after
.
It is important to note that the "sunshines" are not images, but actual html elements:
<div className={css.container}>
<div className={css.shine1}></div>
<div className={css.shine2}></div>
<div className={css.shine3}></div>
</div>
.container {
position: absolute;
display: inline;
top: 20px;
right: 5px;
div {
position: absolute;
height: 5px;
border-radius: 5px;
background-color: $mainColor;
transform-origin: bottom left;
}
.shine1 {
width: 26px;
transform: rotate(-95deg) translate(20px, 5px);
}
.shine2 {
width: 32px;
transform: rotate(-45deg) translate(20px);
}
.shine3 {
width: 26px;
transform: rotate(0deg) translate(15px);
}
}
This code snippet is written in JSX with scss modules, but follows a similar syntax as HTML and CSS.
If you have any suggestions on how to achieve this, please share your ideas. It seems feasible considering CSS can determine the end of a line for background changes.