gpt4 book ai didi

css - 只显示光标(插入符号)但隐藏输入中的字母

转载 作者:行者123 更新时间:2023-12-04 18:34:44 24 4
gpt4 key购买 nike

是否有 css 方式在透明输入中显示光标?我一直在谷歌搜索,所有弹出的都是如何隐藏它!

<input class='transparent' />

.transparent{
color:transparent;
background:transparent;
}

为了绝对清楚,我想在输入中显示的唯一内容是光标,没有别的 - 即文本应该被隐藏,但光标应该仍然可见。

最佳答案

您可以使用 text-fill-color 设置不接触插入符号的文本样式。 webkit 的特性。

 .transparent{
background:transparent;
color:black; /* sets the color of both caret and text */
-webkit-text-fill-color: transparent; /* sets just the text color */
}
<input class='transparent' />


并非所有浏览器都支持该功能,但最广泛使用的浏览器的最新版本确实支持它。

关于css - 只显示光标(插入符号)但隐藏输入中的字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37862843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com