input[type=file] 上传按钮隐藏“未选择任何文件”

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 指定标签

input[type=file] 上传按钮隐藏“未选择任何文件”

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 指定标签
  • 手机扫描二维码访问

      本文标题:《input[type=file] 上传按钮隐藏“未选择任何文件”》作者:极四维博客
      原文链接:https://cway.top/post/948.html
      特别注明外均为原创,转载请注明。

      分享到微信

      扫描二维码

      可在微信查看或分享至朋友圈。

      相关文章

      发表评论:

      ◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

      «    2025年5月    »
      1234
      567891011
      12131415161718
      19202122232425
      262728293031

      搜索

      控制面板

      您好,欢迎到访网站!
        查看权限

      最新留言

      文章归档

      • 订阅本站的 RSS 2.0 新闻聚合