1、关联调用,隐藏上传框
<button onclick="chooseFile.click()"> 上传文件 </button>
<input type="file" id="chooseFile" style="display:none;">
参考 https://blog.csdn.net/qq_28306215/article/details/85322944
2、使用 label for 指定标签
css
.upload_bp input[type='file']{display: none;}
.loadbp{
padding: 0 30px;
height: 40px;
border: 1px solid #dd5923;
color: #dd5923;
font-size: 16px;
display: flex;
align-items: center;
box-sizing: border-box;
}
.loadbpsuccess{
height: 40px;
background: #f5f7f9;
border-radius: 2px;
font-size: 16px;
line-height: 40px;
padding: 0 30px;
color: #262626;
letter-spacing: 0;
text-align: center;
margin-left: 15px;
box-sizing: border-box;
position: relative;
}
.loadbpsuccess span{
font-size: 20px;
color: #000;
position: absolute;
top: -10px;
right: 2px;
}
html
<div style="display:flex;align-items: center;">
<label class="upload_bp" for="fileinp">
<input type="file" id="fileinp">
<p class="loadbp"> 上传附件 </p>
</label>
<p class="loadbpsuccess"> 附件 1.pdf <span>×</span></p>
</div>
参考:https://blog.csdn.net/Dilemma_me/article/details/100120542
目录
- 1、关联调用,隐藏上传框
2、使用 label for 指定标签
目录
- 1、关联调用,隐藏上传框
2、使用 label for 指定标签