javascript - 自定义 <input type ="file"> 在 IE 中不起作用

标签 javascript jquery html css

我正在尝试使用自定义 < input type="file"> 按钮。这适用于 chrome 和 FF。如何让它在 IE 10 及更高版本中工作?

IE的问题是浏览框打不开。

html:

<button type="button" id="fileT"><input type="file" id="file"></button>

CSS:

#fileT{
    overflow: hidden;
    position: relative;
}
#fileT input {
    position: absolute;
    opacity: 0.1
}

最佳答案

我明白你的意思了:因为<input type="file"/>很难设计,你需要一个容器。 然后尝试使用 <div>而不是 <button> .

只需确保指定高度和宽度,因为 div 内容将被绝对定位(因此从流中剥离)。

Running demo :

<div id="fileT">
    <input type="file" id="file" />
</div>

#fileT{
    overflow: hidden;
    position: relative;
    width: 75px;
    height: 50px;
}
#fileT input {
    position: absolute;
    opacity: 0.5;
}

关于javascript - 自定义 &lt;input type ="file"> 在 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25991907/

相关文章:

javascript - 使用 jQuery 找到 child 的索引?

javascript - 如何在单击表格中的按钮时添加动态行?

html - Mailchimp - 如何在浏览器缩小时调整表格大小并隐藏元素 - html/css

来自 cytoscape 的 Javascript 不是函数

javascript - Tradingview 简单移动平均线小部件配置

javascript - 将 utc 时间戳设为本地 24 小时制,然后转换回 utc

javascript - 遍历递归json树并合并

javascript - 事件处理程序的动态附件不起作用

javascript - jQuery 将 td onclick 值传递给其他表

javascript - HeatMap - 使用 JSON 数据的 dc.js 和 d3.js