【问题标题】:How to remove the Blinker from input box in HTML如何从 HTML 的输入框中删除 Blinker
【发布时间】:2019-01-24 06:01:23
【问题描述】:

我想知道是否有办法移除输入中的闪光灯。我看过一些没有闪光灯的网站,但是我找不到任何与之相关的代码。

提前致谢

【问题讨论】:

  • 这不起作用,先生,:/

标签: javascript html css


【解决方案1】:

试试这个

.blinker {
    color: transparent;
    text-shadow: 0 0 0 gray;

}
<input type="text"   class="blinker">

【讨论】:

  • 干净简洁
【解决方案2】:

您可以使用caret-color: transparent; - 但是,它没有最好的浏览器支持。

input {
  caret-color: transparent;
}
<input type="text">

【讨论】:

    【解决方案3】:

    尝试使用这个 css:

    input {
       color: transparent;
       text-shadow: 0 0 0 #2196f3;
    
       &:focus {
        outline: none;
       }
    }
    

    【讨论】:

      【解决方案4】:

      在此处查看 Lajos Meszaros 的答案 https://stackoverflow.com/a/23472096/2929068 这些似乎是您可以采取的所有选项来实现您正在寻找的相同行为。

      基本思想是,光标的颜色与文本的颜色相同。因此,您要做的第一件事就是使文本透明,从而将光标移开。然后您可以使用文本阴影再次显示文本,使用此链接在jsfiddle 中查看它

      input[type="text"]{
          color : transparent;
          text-shadow : 0 0 0 #000;
      }
      input[type="text"]:focus{
          outline : none;
      }
      <input type="text" value="test message" />

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-03-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-07
        • 2021-09-30
        • 2011-01-18
        • 2013-11-22
        相关资源
        最近更新 更多