Css 对不可编辑的表单字段使用范围或输入元素
我刚开始 我想创建一个禁用的表单字段。在文档中,我发现了以下片段:Css 对不可编辑的表单字段使用范围或输入元素,css,html,twitter-bootstrap,Css,Html,Twitter Bootstrap,我刚开始 我想创建一个禁用的表单字段。在文档中,我发现了以下片段: <input type="text" placeholder="Disabled input here..." disabled> 这也适用于IE9和chrome。哪个解决方案更好(与IE8、7(和6)等旧浏览器兼容)?占位符属性是HTML5,在许多浏览器中不起作用,尤其是在旧浏览器中,这就是为什么它在IE9中不起作用的原因。(微软甚至在IE9中也不遵循标准。) 如果您的问题是span是否比占位符属性更兼容,那么是
<input type="text" placeholder="Disabled input here..." disabled>
这也适用于IE9和chrome。哪个解决方案更好(与IE8、7(和6)等旧浏览器兼容)?占位符属性是HTML5,在许多浏览器中不起作用,尤其是在旧浏览器中,这就是为什么它在IE9中不起作用的原因。(微软甚至在IE9中也不遵循标准。)
如果您的问题是span是否比
占位符
属性更兼容,那么是的。所有浏览器都应该支持span。IE 7/8/9不支持HTML5占位符。最好的解决方案必须是使用提供功能的脚本/插件(当它不存在时)
看
我在这方面也有很好的经验
如果HTML5可用,他们都会使用,如果不可用,他们也会模仿HTML5
它们使用起来非常简单。例如,要使用水印,只需包含它并在文档中添加一行即可。ready()
您可以使用javascript替代方案
<input type="text" placeholder="Disabled input here..." onfocus="this.blur()" />
这里有些值
他比我强
原因-它将在新旧浏览器中按预期运行,不依赖任何外部脚本,只依赖css样式的不可编辑的输入
当您可以简单地在
span
标记中回显您的值时,为什么要使用禁用的表单字段..???我发现,当我要使用
我必须使用输入元素。它与span元素不兼容
例如:
<div class="input-prepend">
<span class="add-on">@</span>
<input class="span2" id="prependedInput" type="text" placeholder="Username">
</div>
<div class="input-append">
<input class="span2" id="appendedInput" type="text">
<span class="add-on">.00</span>
</div>
@
.00
<input type="text" placeholder="Disabled input here..." onfocus="this.blur()" />
<span class="uneditable-input">Some value here</span>
<div class="input-prepend">
<span class="add-on">@</span>
<input class="span2" id="prependedInput" type="text" placeholder="Username">
</div>
<div class="input-append">
<input class="span2" id="appendedInput" type="text">
<span class="add-on">.00</span>
</div>