我该如何让这个输入框透明?
<input type="text" class="foo">
我尝试过这个方法,但它没有起作用。
background:transparent url(../img/transpSmall.png) repeat scroll 0 0;
我该如何让这个输入框透明?
<input type="text" class="foo">
我尝试过这个方法,但它没有起作用。
background:transparent url(../img/transpSmall.png) repeat scroll 0 0;
input[type="text"]
{
background: transparent;
border: none;
}
没有人会知道它的存在。
`input[type="text"],
input[type="text"]:focus
{
background: transparent;
border: none;
outline-width: 0;
}`
请注意,这不会改变原来的意思,只是使内容更加通俗易懂。 - Mubramajoutline: none;
。 - Yasser CHENIK我喜欢做这个
input[type="text"]
{
background: rgba(0, 0, 0, 0);
border: none;
outline: none;
}
outline
属性设置为none
可以防止浏览器在光标进入时突出显示框。outline: none
会破坏键盘可访问性。请参见@derekshirk的答案。 - Volker E.之前描述的两种方法在今天已经不够用了。我个人使用:
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;
}
它还会消除在某些浏览器上设置的阴影,隐藏可能输入的文本,并使光标的行为表现得好像该输入不存在。
您可能还希望将宽度设置为0px。
如果你想在聚焦时同时删除轮廓,请尝试以下方法:
input[type="text"],
input[type="text"]:focus
{
background: transparent;
border: none;
outline-width: 0;
}
我将不透明度设置为0。这使它消失了,但仍然可以在单击时正常工作。
display: fixed; right: -1000px;
将其扔到屏幕外。当你需要一个输入框来复制到剪贴板时,这非常有用。 :)outline
或 :focus
样式。
https://a11yproject.com/posts/never-remove-css-outlines
使用outline: none
而没有适当的回退会使您的网站对任何仅使用键盘的用户,而不仅仅是视力受损的用户,显著降低可访问性。请确保始终为您的交互元素提供可见的焦点指示。