如何使文本输入不可编辑? [英] How do I make a text input non-editable?

查看:142
本文介绍了如何使文本输入不可编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个文本输入

 < input type =textvalue =3class =左> 



这是我的CSS

  background:url(images / number-bg.png)no-repeat scroll 0 0 transparent; 
border:0 none;
color:#FFFFFF;
height:17px;
margin:0 13px 0 0;
text-align:center;
width:17px;

这是一个设置还是一个技巧,我想在做一个标签,造型。如何转换它们,是否有更好的方法或者是唯一的方法?

解决方案

 < input type =textvalue =3class =field leftreadonly> 

不需要样式。



code>< input> 在 https: //developer.mozilla.org/en/docs/Web/HTML/Element/input#Attributes


So I have a text input

<input type="text" value="3" class="field left">

Here is my CSS for it

background:url("images/number-bg.png") no-repeat scroll 0 0 transparent;
border:0 none;
color:#FFFFFF;
height:17px;
margin:0 13px 0 0;
text-align:center;
width:17px; 

Is there a setting or a trick to this, I was thinking of doing a label instead but how about the styling. How do I convert them and is there a better way or is that the only way?

解决方案

<input type="text" value="3" class="field left" readonly>

No styling necessary.

See <input> on MDN https://developer.mozilla.org/en/docs/Web/HTML/Element/input#Attributes

这篇关于如何使文本输入不可编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆