关于修改<input type=‘file‘>自定义上传样式

哈喽 大家好啊  最近遇到一个问题,就是上传文件<input type="file">样式自定义

1.首先讲input设置display:none

 input[type=file] {
  display: none;
}

 2.然后写一个label,这里面写我们自己定义的class样式

特别注意,label 有一个for 样式和input的id保持一致

label中的for属性规定了label与哪个表单元素绑定。for属性的值和表单元素的id值一样,即可完成该label标签与该表单元素的绑定。

<div class="enCodeFileUpload-container">'
     <div class="webuploader-pick">'
          <label class="lee-upload-fileicon l-icon-upload-big" for="fileUpload">
            文件解密            
          </label>'
           <input type="file"  onchange="sendFile(event)" id="fileUpload"/>'
     </div>'
</div>'

 如上所示,该label便签和input便签完成了绑定,当鼠标点击“label标签”时,input元素会被触发,用户即可完成输入。

.enCodeFileUpload .enCodeFileUpload-container .webuploader-pick:hover {
    border: 1px dashed #2A87FF;
}
.enCodeFileUpload .enCodeFileUpload-container .webuploader-pick input:hover {
    cursor: pointer;
}
.enCodeFileUpload .enCodeFileUpload-container .webuploader-pick input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: none;
    border: none;
}
.enCodeFileUpload .enCodeFileUpload-container .webuploader-pick {
    position: relative;
    display: inline-block;
    cursor: pointer;
    padding: 5px 10px;
    text-align: center;
    border-radius: 2px;
    overflow: hidden;
    border-color: #2A87FF;
    box-shadow: none;
    background: #FAFCFD;
    border: 1px dashed #D8DFED;
    border-radius: 6px;
}

参考原文:

(1条消息) 如何更简单地更改 input type=file 文件选择框的样式_Web_boom的博客-CSDN博客

(1条消息) label标签中的for属性_label for_在线小白www的博客-CSDN博客

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
table { border-collapse: collapse; width: 100%; } td, th { border: 1.5px solid black; padding: 5px; } table img { max-width: 150px; height: auto; } <table id="myTable"> <thead class="sticky-header"> <tr> <td contenteditable="true"><input type="text" oninput="filterTable(0)" placeholder="工艺膜层"></td> <td contenteditable="true"><input type="text" oninput="filterTable(1)" placeholder="AOI Step"></td> <td contenteditable="true"><input type="text" oninput="filterTable(2)" placeholder="不良类型"></td> <td contenteditable="true"><input type="text" oninput="filterTable(3)" placeholder="Layer(Code)"></td> <td contenteditable="true"><input type="text" oninput="filterTable(4)" placeholder="Type"></td> <td contenteditable="true"><input type="text" oninput="filterTable(5)" placeholder="Dpet"></td> <td contenteditable="true"><input type="text" oninput="filterTable(6)" placeholder="Subcode"></td> <td contenteditable="true">Code描述</td> <td contenteditable="true">Image1</td> <td contenteditable="true">Image2</td> <td contenteditable="true">Image3</td> <td contenteditable="true">Image4</td> <td contenteditable="true">Image5</td> <td contenteditable="true">Image6</td> <td contenteditable="true">判定细则</td> </tr> </thead> <tbody> <tr> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;" > </td> <td> <input type="file" onchange="previewImage(this)"onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)"onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td contenteditable="true">Particle</td> </tr> </tbody> </table>这个表格怎么设置自定义调整列宽
07-16

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值