时间:2020-10-11来源:www.pcxitongcheng.com作者:电脑系统城
1. 去掉input 在iOS中的默认圆角和内阴影
iOS下 input会有自带的圆角和内阴影,去掉方法如下:
?| 1 2 3 4 |
input{ -webkit-appearance: none; border-radius: 0;} |
2. 焦点在 input 时,placeholder 没有隐藏
?| 1 2 3 |
input:focus::-webkit-input-placeholder{ opacity: 0;} |
3. input 输入框调出数字键盘
单独使用type="number"时,iOS调起的并不是九宫格样式的数字键盘,如果需要调起九宫格的数字键盘需要加上 pattern="[0-9]*" 属性
?| 1 2 3 4 5 6 7 8 |
<!-- 数字键盘 带有符号,非九宫格样式 --><input type="number"/><!-- 九宫格数字键盘 --><input type="number" pattern="[0-9]*"/><!-- 电话号码键盘 --><input type="tel"/> |
4. 搜索时,键盘的回车按钮文字设定为“搜索”
解决: input 使用 type="search",放在 form 表单内。两者结合就能使输入法中的回车按钮文字变为“搜索”
?| 1 2 3 |
<form action=""> <input type="search" /></form> |
5. 改变input placeholder颜色
?| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
::-webkit-input-placeholder { /* WebKit browsers */ color: #999;}:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #999; opacity: 1;}::-moz-placeholder { /* Mozilla Firefox 19+ */ color: #999; opacity: 1;}:-ms-input-placeholder { /* Internet Explorer 10+ */ color: #999;}input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { /* WebKit*/ color: #666; } input:-moz-placeholder, textarea:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #666; } input::-moz-placeholder, textarea::-moz-placeholder { /* Mozilla Firefox 19+ */ color: #666; } input:-ms-input-placeholder, textarea:-ms-input-placeholder { /* IE 10+ */ color: #666; } |
6. iOS下autofocus focus()失效的问题
iOS下不能自动获取焦点,必须是在监听到用户发出的事件的函数中执行focus才有用,比如:
?| 1 2 3 4 5 6 7 8 |
// openNotifyReplay 是click触发的事件openNotifyReplay = (e) => { this.setState({ notifyReplayVisible: true }, ()=>{ document.getElementById("replayPopupText").focus() })} |
到此这篇关于移动端HTML5 input常见问题(小结)的文章就介绍到这了,更多相关移动端HTML5 input内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,
2026-06-09
win10系统以太网连接图标不见了怎么办 Win10 / Win11 找不到以太网通用解决方法2024-04-11
台式机电脑如何连接外接显示器2024-04-11
小新系列打印机手机配置网络的方法教程一、40系列之后机型 X(250、240s、240、230s) X1 carbon(20BT/20BS) YOGA 11e T(550、540p、450s、450、440s、440p、440、431s) W(550s、540、541) L(450、440、550) E(550、55...
2024-04-11
ThinkPad蓝牙鼠标如何配对解答步骤41U5008鼠标驱动官网地址: https://support.lenovo.com/en_US/downloads/detail.page?&LegacyDocID=MIGR-67201 第一种方式是比较传统的:使...
2024-04-11