Look, there’s a way that can help you. All right that is not very stylish, and to use the entire site will be kind of boring, but solves the problem in a certain way...
What I’ve done here is wear one custom attr, who I called data-text
and put inside it the same text that is inside the tag. Then I created a pseudo-element ::after
in the element that has the text. And in that ::after
in the CSS I used the content=""
to include the text of data-text
, being like this: content: attr(data-text);
Like I said, maybe it’s not a very practical technique, but in one text or another it can help you.
Note that now when selecting the BG color is no longer above the text!
OBS: I left the comments in the code
.tex_nome::selection {
background: #fff;
}
.det_tex {
position: absolute;
height: 485px;
width: 325px;
background-color:green;
}
.tex_marca{
top:60px;
position: absolute;
font-size: 18px;
font-family: 'Titillium Web', sans-serif;
}
.tex_nome{
top:85px;
position: absolute;
font-size: 30px;
font-weight:bold;
font-family: 'Titillium Web',sans-serif ;
line-height: 26px;
}
.tex_nome:nth-child(2){
top:185px;
}
.tex_nome::after{
/* Aqui seria o texto que vai ficar por cima do texto original */
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
}
<div class="det_tex">
<div class="tex_marca">marca</div>
<div class="tex_nome">Lorem ipsum dolor sit amet consectetur.</div>
<!-- o que estiver no data-text deve ser o mesmo texto dentro da tag -->
<div class="tex_nome" data-text="Lorem ipsum dolor sit amet consectetur.">Lorem ipsum dolor sit amet consectetur.</div>
</div>
post the snippet of your code so we can help.
– Wictor Chaves
I guess there’s no way to avoid it because you’re using a line-height smaller than the font standard.
– Sam
Because then the line-height and the spacing between lines I wanted to keep ,in case I’m using google font.
– Richard Carlos
@Richardcarlos doesn’t want to put HTML in either and put it all in a snippet to make it easier to see the problem and try to help?
– Jorge B.
Transparent color text selection could help?
– Caio de Paula Silva