如何在不影响占位符的情况下在文本框中输入大写字母?

时间:2018-01-13 06:57:02

标签: css html5

我希望我的占位符在标题字母中(例如 - 请输入您的护照号码)和我的所有大写字母输入。它还包含一些数字。 我试过这个:Make input value uppercase in CSS without affecting the placeholder 但是当我尝试这个解决方案时,我页面上的所有条目都在Caps中。我只想要一个特定的条目。

1 个答案:

答案 0 :(得分:0)

也许使用class ...



input.separate { 
    text-transform: uppercase;
    width: 300px;
    height: 35px;
    padding: 0 5px;  
    margin: 5px 0;
}
input { 
	text-transform: none;
    width: 300px;
    height: 35px;
    padding: 0 5px;    
}
::-webkit-input-placeholder { /* WebKit browsers */
    text-transform: capitalize;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
    text-transform: capitalize;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
    text-transform: capitalize;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
    text-transform: capitalize;
}

<input class="separate" type="text" placeholder="please enter your passport number" />
<input type="text" placeholder="please enter your passport number" />
&#13;
&#13;
&#13;