如何从CSS设置文本框的只读属性 [英] How to set readonly property of textbox from css
问题描述
我创建
.inputHide {
font-size : 100px;
width : 100px;
height : 100px;
border : none;
background : transparent;
readonly : true;
}
但是它不起作用.虽然如果我使用1px的字体大小,则可以使用选项卡访问该文本框&可以更改它的值.
But it does not work. Although if i use font-size of 1px then by using tab i can access that textbox & can change it's value.
是否有任何方法可以仅使用css将文本框设置为只读.
Is there any way to make textbox readonly just using css..
推荐答案
我同意rowland,但可以使用以下方法将其设置为不可
I agree with rowland but you can set it uneditable with:
.inputHide {
display: none;
}
尽管这使它从流程中消失了(所以有明显的元素移动来填补文本框的空白).
although this takes it out of the flow (so there is a noticable movement of elements to fill the void your textbox left).
此方法使其完全不可见和不可编辑...不仅可见且呈灰色(就像HTML的禁用"或只读"属性一样).
This method makes it completely invisible and uneditable... not just visible and greyed out (like HTML "disabled" or "readonly" attributes would do).
这篇关于如何从CSS设置文本框的只读属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!