是否有纯CSS方式使输入透明?

fms*_*msf 50 html css

如何使此输入透明?

<input type="text" class="foo">
Run Code Online (Sandbox Code Playgroud)

我试过这个,但它不起作用.

background:transparent url(../img/transpSmall.png) repeat scroll 0 0;
Run Code Online (Sandbox Code Playgroud)

小智 132

input[type="text"]
{
    background: transparent;
    border: none;
}
Run Code Online (Sandbox Code Playgroud)

没有人会知道它在那里.

  • @Metropolis很高兴地报告2016年没有人关心它 (29认同)
  • 这打破了Netscape 1.0和Zune. (11认同)
  • 我的土豆不支持这个 (6认同)
  • 这在IE7中打破了 (4认同)
  • 如果您想在聚焦时删除轮廓,请尝试:`input[type="text"], input[type="text"]:focus {background:transparent; 边框:无;轮廓宽度:0;}` (2认同)

小智 23

我喜欢这样做

input[type="text"]
{
    background: rgba(0, 0, 0, 0);
    border: none;
    outline: none;
}
Run Code Online (Sandbox Code Playgroud)

设置outline属性以none阻止浏览器在光标进入时突出显示该框


fra*_*ank 7

前面描述的两种方法今天还不够.我个人使用:

input[type="text"]{
    background-color: transparent;
    border: 0px;
    outline: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    width:5px;
    color:transparent;
    cursor:default;
}
Run Code Online (Sandbox Code Playgroud)

它还删除了某些浏览器上的阴影集,隐藏了可以输入的文本,并使光标的行为就像输入不存在一样.

您可能还想将宽度设置为0px.


Lou*_*med 7

如果您想在聚焦时删除轮廓,请尝试:

input[type="text"],
input[type="text"]:focus   
{
         background: transparent;
         border: none;
         outline-width: 0;
}
Run Code Online (Sandbox Code Playgroud)