[英]Html input type File style changes are not working
can anyone help me to change the style of input type 'file' in html. 谁能帮助我更改html中输入类型“文件”的样式。 i referred the below links but my problem is not resolved.i need to give color to the browse-button, when i try to apply style to browse-button, the text-box disappears i cant see what file i have selected in the text-box.
我引用了以下链接,但我的问题仍未解决。我需要为浏览按钮添加颜色,当我尝试将样式应用于浏览按钮时,文本框消失了,我看不到我在文本中选择的文件-框。 here is my code:
这是我的代码:
<div id="fileimport">
<div class="fileupload">
<input type="file" name="Upload" style="position: relative" />
</div>
</div>
input.file {
position: relative;
text-align: right;
-moz-opacity: 0;
filter: alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
div.fileupload {
position: relative;
}
$('input[type=file]').on('change', prepareUpload);
function prepareUpload(event) {
files = event.target.value;
if (files != null) {
$("#ShiftValidate").prop('disabled', false);
}
}
input[type=file] {
position: relative;
text-align: right;
-moz-opacity: 0;
filter: alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
The reason the button disappears is because you have opacity: 0
thus making it totally, utterly, thoroughly and completely transparent. 按钮消失的原因是因为您具有
opacity: 0
从而使其完全,完全,彻底和完全透明。 Ie invisible. 即不可见。 HG Well's invisible man did it by giving himself an opacity of zero!
HG威尔的隐形人做到了,将自己的不透明度设为零! Try a value such as
opacity: 0.5
. 尝试输入诸如
opacity: 0.5
的值。
But Irfan's answer is needed as well, to correct your syntax. 但是也需要Irfan的答案来更正您的语法。
Basically you need to hide the file input and replace it with a wrapping element. 基本上,您需要隐藏文件输入并将其替换为包装元素。 And then you need to do some js to get the name of the file you're uploading and put that into another input.
然后,您需要执行一些js来获取要上传的文件的名称,并将其放入另一个输入中。
<div class="btnWrap"> <span class="text">Choose file</span> <input type="file" name="file"> </div> <input type="text" class="fileNames" value="No file selected">
I made a pen for you: http://codepen.io/eplehans/pen/gbpZoQ 我为您制造了一支笔: http : //codepen.io/eplehans/pen/gbpZoQ
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.