我不希望用户看到输入的文本,我已经使用了color: transparent
并且文本是隐藏的,但是当用户双击输入时,文本变得可见!通过双击选择输入时如何隐藏它。 提前谢谢。
#loginCard{
color: transparent;
}
<!DOCTYPE html>
<html>
<head></head>
<body>
<input type="text" autocomplete="off" id="loginCard">
</body>
</html>
在 CSS 中使用此代码更改标记突出显示颜色的文本
注意:您也可以在颜色中使用transparent
。我使用白色,因为背景是白色的。但是使用transparent
会更明智。
::selection {
background: #ffb7b7; /* WebKit/Blink Browsers */
}
::-moz-selection {
background: #ffb7b7; /* Gecko Browsers */
}
::selection {
background: #fff; /* WebKit/Blink Browsers */
}
::-moz-selection {
background: #fff; /* Gecko Browsers */
}
.sample {
color: #fff;
}
<input type="text" class="sample" />
只需添加
::selection {
background: transparent;
}
对于火狐:
::-moz-selection {
background: transparent;
}
我不知道你为什么要这样做,但你可以使用 css:
input, textarea {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
input::selection {
color: transparent;
background: transparent;
}
将使其透明
您可以使用设置为transparent
::selection
支持
input {
color: transparent;
}
input::selection {
color: transparent;
}
<input>
Html
<input type="password" id="password" >
Jquery
$(document).ready(function(){
$('#password').dblclick(function(){
$('#password').attr("type","text");
})
});