【发布时间】:2016-06-10 01:03:49
【问题描述】:
我正在尝试更改输入类型文件的样式。跟随 CSS 在 Chrome 和 Opera 上运行良好,但在 Mozilla Firefox 上运行不佳。
HTML
<input type="file" class="custom-file-input" />
CSS
.custom-file-input::-webkit-file-upload-button {
visibility: hidden;
}
.custom-file-input::before {
content: 'UPLOAD';
display: inline-block;
background: -webkit-linear-gradient(top, black, red);
border: 1px solid #999;
border-radius: 3px;
padding: 5px;
outline: none;
white-space: nowrap;
-webkit-user-select: none;
cursor: pointer;
font-size: 10pt;
color:#fff;
}
.custom-file-input:hover::before {
border-color: #fff;
}
.custom-file-input:active::before {
color:#666;
background: -webkit-linear-gradient(top, bclack, red);
}
http://jsfiddle.net/Rameshpardhi/3agapfw3/
我也把我的风格改成了这样:
.custom-file-input::-moz-file-upload-button {
visibility: hidden;
}
.custom-file-input::before {
content: 'UPLOAD';
display: inline-block;
background: -moz-linear-gradient(top, black, red);
border: 1px solid #999;
border-radius: 3px;
padding: 5px;
outline: none;
white-space: nowrap;
-moz-user-select: none;
cursor: pointer;
font-size: 10pt;
color:#fff;
}
.custom-file-input:hover::before {
border-color: #fff;
}
.custom-file-input:active::before {
color:#666;
background: -moz-linear-gradient(top, bclack, red);
}
但它仍然无法正常工作。我想知道为什么这个 css 不能在 Mozzila 上运行?
【问题讨论】:
-
尝试将 -moz- 放在这样的属性前面:-moz-linear-gradient(top, bclack, red);
-
解释出了什么问题以及应该发生什么
-
没有
-webkit-file-upload-button的firefox版本:developer.mozilla.org/en-US/docs/Web/CSS/Reference/… -
我不知道它是否重复,但我不是在问如何设置输入类型文件的样式,我要问的是为什么这个 css 在 mozilla 上不起作用?
标签: html css firefox input-type-file