基本上我想隐藏输入文件并使用按钮来选择表单中的文件.
如果我<label for="input-file">Label</label>在单击标签时使用,我可以选择一个文件,但我想成为一个按钮或者至少看起来像一个按钮.
这是JSFiddle中的代码示例:
input[type=file] { display: none; }
<form>
    <input type="file" id="input-file">
    <label for="input-file">
        <button>Button</button>
    </label>
    <input type="submit">
</form>
如果我只是标签中的一个按钮,它就像一个提交按钮,如果我指定它的类型,它在点击时什么都不做.
是否有任何方法可以使用我的按钮或按钮查看控件而不是使用input type="file"?来在表单中上传文件?
它必须是HTML-CSS解决方案,没有JS或任何框架.
编辑:
这个CSS代码label看起来像一个标准按钮:
label {
    appearance: button;
    -moz-appearance: button;
    -webkit-appearance: button;
    text-align: center;
    padding: 2px 6px 3px;
    border: 2px outset buttonface;
    font: 13.3333px Arial;
}
Aks*_*shi 20
你可以通过几行CSS实现这一目标.小提琴
input[type="file"] {
    display: none;
}
.custom-file-upload {
    border: 1px solid #ccc;
    display: inline-block;
    padding: 6px 12px;
    cursor: pointer;
}<label for="file-upload" class="custom-file-upload">
    <i class="fa fa-cloud-upload"></i> Custom Upload
</label>
<input id="file-upload" type="file"/>你的 Html 带有简单的字体很棒的自定义Fiddle
.image-upload > input
{
    display: none;
}
.attach-doc
{
    cursor: pointer;
}<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="image-upload">
    <label for="file-input">
        <i class="attach-doc fa fa-paperclip fa-2x" aria-hidden="true"></i>
    </label>
    <input id="file-input" type="file"/>
</div>| 归档时间: | 
 | 
| 查看次数: | 18097 次 | 
| 最近记录: |