//由于IE8无法模拟点击事件,最好的方法就是将input[type=file]的按钮附在新的按钮上访,设置opacity:0
<!--html-->
<input name="filePuppet" id = "filePuppet" readonly class = "file-add"
title= "点击此处添加文件" type="text" value="文件上传"
scvalidate='{"required":true,"format":"lng"}' onclick="document.getElementById('filePuppet').click()"/>
<input type="file" unselectable="on" class = "file-up" id="guidefile" name="file">
<!--less-->
.file-up{
margin: -60px 0 0 0;
display: block;
height: 50px;
width: 160px;
opacity: 0;
filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
}
.file-add{
height: 50px;
width: 160px;
<!--该按钮可以自行设置样式-->
}
//这种方法会在IE10以下的浏览器出现被覆盖的按钮部分区域点击无效,解决方法是将透明的input的font-size设置大些。
//IE10、IE11已经不提供html里 <!--[if 。。。]><![endif]-->,可以通过js来判断
function isIE10(){
var ua = navigator.userAgent;
if(ua.toLowerCase().indexOf("msie") > 0){ //判断是否是IE10以下浏览器
$('#guidefile').css('font-size','150px')
}
}
兼容IE10以下 设置上传文件新样式
最新推荐文章于 2024-08-11 18:40:36 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)