Changing the height of selection highlight
Asked Answered
R

1

8

Is there a way to change the height of the text selection highlight without changing the line-height of the element that contains it?

Thanks.

Rebeckarebeka answered 18/12, 2012 at 10:38 Comment(8)
No. What is wrong with changing the line-height?Retral
what exactly you want to do? Example?Jesselyn
Well, for some reason the selection highlight is all fine for the whole text in my application, except for the first line of paragraphs. The first lines does not have any styling other than the one that all the other lines have and they are not in any additional containers. Like so: <p> Lorem ipsum (screen is as wide as to contain only these words) dolor sit amet </p> Now if I select Lorem ipsum selection is let's say 10px tall. If I select dolor sit amet or any of the following text, it is 20px tall. If I set the line-height of the first line of the paragraph to 3em highlight is ok.Rebeckarebeka
However, setting the line height of the first-line changes the height of the following line and the preceding lines too. :/ I cannot reproduce this in a desktop Chrome, so it might be some bug in the webview implementation on the platform I use.Rebeckarebeka
make sure line-height for other elements is 3px too.Postmillennialism
Changing the line-height of the other lines, makes the selection highlight height for them again bigger than the one for the first lines. Besides I can't really change the line height as there are design specs that I need to follow.Rebeckarebeka
Why does the selection highlight matter? No offense, but this sounds silly.Rebellion
I think you need to change the font-size. The line-height does not change the selection square. It depends on em size of the font? -- rhytorical questionDoubletime
M
2

If you want to do this with CSS only the the answer is NO.

Only a small subset of CSS properties can be used in a rule using ::selection in its selector: color, background, background-color and text-shadow. Note that, in particular, background-image is ignored, like any other property. https://developer.mozilla.org/en-US/docs/CSS/::selection

Menendez answered 18/12, 2012 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.