我有这样的 CSS 类:
.new-fld input[type="text"]{width:418px !important; margin-bottom:0px !important; height:18px !important; background-color:transparent !important; color:#FFF !important; border-bottom:1px solid #FFF; border-left:none !important; border-right:none !important; border-top:none !important; font-size:14px; /*padding:0 8px;*/}
它应用于页面上的所有输入字段。
我希望一些字段的长度不同,所以我创建了另一个这样的类
.new-fld input[type="text"]{width:45px !important; margin-bottom:0px !important; height:18px !important; background-color:transparent !important; color:#FFF !important; border-bottom:1px solid #FFF; border-left:none !important; border-right:none !important; border-top:none !important; font-size:14px; /*padding:0 8px;*/}
然后像这样应用它
<div class="new-fld">
<input type="text" value="+44 1793 853219" name="">
<input type="text" value="+ 44" readonly="readonly" name="Dialprefix1" id="Dialprefix1" class="dialprefix" style="text-align:right;width:45px;">
<span>*</span>
</div>
如您所见,我在文本框样式中输入了宽度,但它仍然不起作用。
但是它不起作用。请给我建议好的解决方案。
最佳答案
使用
<input type="text" value="+ 44" readonly="readonly" name="Dialprefix1" id="Dialprefix1" class="dialprefix" style="text-align:right" size='10' />
并检查结果。
好的,这将解决您的问题(但我希望有充分的理由将 !important 添加到所有样式):
<input type="text" value="+ 44" readonly="readonly" name="Dialprefix1" id="Dialprefix1" class="dialprefix" style="text-align:right;width:45px !important;">
关于css - 使用css改变文本框的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15044163/