如何使用 CSS 删除输入文本值选择突出显示? [英] How to remove input text value selection highlighting with CSS?
本文介绍了如何使用 CSS 删除输入文本值选择突出显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 CSS 禁用输入字段中文本值的选择突出显示.我已使用以下代码为文本禁用它,但它不适用于输入字段:
I am trying to disable selection highlighting for the text value in input fields using CSS. I have disabled it for text using the below code, but it doesn't apply to input fields:
.inputTest {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
推荐答案
Use ::selection
如果你的文本框背景是白色,给背景颜色白色
Use ::selection
Give background color white if your textbox background is white
::selection {
background: #ffb7b7; /* WebKit/Blink Browsers */
}
::-moz-selection {
background: #ffb7b7; /* Gecko Browsers */
}
查看此演示
input::selection {
background: #FFF; /* WebKit/Blink Browsers */
}
input::-moz-selection {
background: #FFF; /* Gecko Browsers */
}
<input type="text" value="Try to highlight me"/>
这篇关于如何使用 CSS 删除输入文本值选择突出显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文