- 改变 placeholder 颜色
::-webkit-input-placeholder { /* WebKit, Blink, Edge */ color: #f00; } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #f00; opacity: 1; } ::-moz-placeholder { /* Mozilla Firefox 19+ */ color: #f00; opacity: 1; } :-ms-input-placeholder { /* Internet Explorer 10-11 */ color: #f00; }
- 输入框聚焦时,去除边框
input边框使用border修改样式,但是聚焦高亮时修改border 没有效果,需要使用outline
<input class="ipt1" type="text" value="" placeholder="请输入" /> <style> .ipt1 { max-width: 10rem; height: 1.56rem; font-weight: 600; font-size: 1.13rem; color: #0b8cbf; line-height: 1.56rem; text-align: end; border: none; &:focus { outline: 0; border: none; } } </style>
原生 input 记录
最新推荐文章于 2024-05-07 14:16:18 发布
文章介绍了如何使用CSS伪类(::-webkit-input-placeholder,::-moz-placeholder等)改变输入框placeholder的颜色,并在输入框聚焦时去除边框,同时处理不同浏览器的兼容性问题。着重讲解了:focus状态下的边框处理和outline的使用。
摘要由CSDN通过智能技术生成