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

标签 css html

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

最佳答案

也许使用 ...

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" />

关于css - 如何在不影响占位符的情况下在文本框中输入大写字母?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48237623/

相关文章:

javascript - 在 polymer 中注入(inject) html,包括数据绑定(bind)

jquery - 由于选择元素的大小,Bootstrap 选择选项被隐藏

javascript - 表单验证只验证第一个字段

javascript - JavaScript 中的探路者

html - Tahoma 文字看起来不流畅

jquery - 与 jQuery 选择器一起使用的 CSS 类命名的最佳实践

jquery - 使用 Jquery 在悬停时更改图像?

html - CSS - 线性渐变的清晰边界

html - 图片在响应式手机/平板电脑上可见,但在桌面上隐藏

javascript - 选择框值未在引导模式上设置