Hi i am customizing a wordpress theme and on majority of my pages i’ve got a transparent layer behind the heading of the page. I would like to keep it in the same position on every viewport but just can’t seem to get it right.
If I understand it correctly, you want to keep the right edge of the background layer in position relative the text in the heading. Even if the font-size and heading position can change and maybe also the title text.
To achieve this you could position the background layer in a spot that is the same in all cases, and form there move the layer based on font-size.
So, the position of the slanted right edge of the layer would meet the base-line where the title text starts, and the whole slanted bottom edge be moved below the title container’s bottom.
Then from that position you can use margins with the em unit to move the layer to a consistent point in the title text.
Because the heading-title has a position to base the layer’s coordinates on, no media rules should be needed.