移动端可能遇到的问题解决方案

本文介绍了移动端开发中的若干实用技巧,包括取消iOS首字母大写、实现移动端键盘搜索按钮、消除元素触摸高亮、更改表单占位符颜色、禁止图片长按保存及文字选中、实现拍照功能等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.ios如何取消首字母大写

 <input type="text" autocapitalize="off"> 

2.移动端input键盘右下角搜索按钮

 <form action="" onsubmit="return false">
            <input type="search">
        </form>
解决方式:要一层form;
追杀问题:键盘如何收起 document.activeElement.blur();

3.页面元素被触时产生的半透明灰色蒙层怎么解决 a button input  textarea这些标签被触发时都会有

解决方式:通过css样式来解决
input::-webkit-tap-highlight-color:rgba(0,0,0,0)

4.表单输入框placeholder的颜色可以改变吗

input::-webkit-input-placeholder{color:red}

5. 禁止ios或者安卓的长按保存图片

img{
        -webkit-touch-callout:none;
    }

6.如何禁止ios或者安卓长按选中文字

p{
                -webkit-user-select:none;
            }

7.移动端拍照怎么做

需求:
1、拍照的需求
2、不能在相册选择照片,只能拍照
3、并且拍照后的图片,要显示在页面上
解决:

1、本身input type为file有拍照功能,但是显示效果不好,
所以解决方式:让input隐藏掉,然后让button显示,点击button触发input

<button onclick='document.getElementById("myFile").click()'>拍照</button>
<input type="file" capture='camcorder' accept="image/*" style="display: none;" id='myFile'>

2、只是拍照

<input type="file"  capture='camcorder' accept="image/*" style="display: none;" id='myFile'>

最主要: capture='camcorder'

3. 放入图片

var btn = document.getElementById('btn');
            var myFile = document.getElementById('myFile');
            btn.onclick = function(){
                myFile.click();
                myFile.onchange = function(){
                    var myFile = document.getElementById('myFile');
                    var file = myFile.files[0];
                    var fileReader = new FileReader();
                    fileReader.onloadend = function(){
                        if( fileReader.readyState == fileReader.DONE ){
                            document.getElementById('vPhoto').setAttribute('src',fileReader.result);
                        }
                    }
                    fileReader.readAsDataURL(file);
                }
            }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值