I wracked my brain trying to move ‘heading-to-remove-on-small-screens’ after the paragraph on smaller screens:
<div class="container">
<h3 class="heading">
I consist of the main part
<span class="heading-to-remove-on-small-screens pink">
and the part that should go down on smaller sreens
</span>
</h3>
<p>I am the one who splits the heading on smaller screens</p>
</div>
Basically, I’m trying to get something like this:
<div class="container">
<h3 class="heading">
I consist of the main part
</h3>
<p>I am the one who splits the heading on smaller screens</p>
<h3 class="heading-to-remove-on-small-screens pink">
and the part that should go down on smaller sreens
</h3>
</div>
Nothing except for duplicating the text in layout and manipulate it in CSS comes to my mind but that’s considered a bad practise. I’m supposed to solve it with pure CSS.
I’d greatly appreciate some help!
I tried making the container a grid/flex but in this case, on bigger screens my heading doesn’t look like solid text (parts have a line break)
2
Answers
You might do it like this (run the snippet and switch to fullscreen and back):
and read the comments in CSS.
Use
::after
pseudo-element and media queries to get required behavior. View in Full page mode and then resize the window. Details are commented in example.