form input file 图片上传360IE兼容问题


    <form action="" class="form-box" class="form_box" enctype="multipart/form-data" > <label for="upload" class="label_bg"></label> // 错误的做法,不需要用 for来关联input <label class="label_bg"></label> // 正确的做法 <input type="file" id="upload" class="uploadInpt" name="file" accept=".jpg, .png" /> </form>
一、上面是html文档结构

二、出现的问题:前端用form表单做图片上传 这种方法在其他浏览器下都是正常的,但有个奇葩的浏览器360兼容模式 会出现点击上传, 然后弹框就突然消失了

三、解决办法 label标签中不要用 for来关联input, 直接给input设置宽高,定位到label背景标签上,并且input的透明度设置为0,就可以解决这个问题
原文地址:https://www.cnblogs.com/zsongs/p/6047168.html