如何将file对象的显示信息自定义?

<input type="file" />
用浏览器打开效果如图

图片描述
我有什么办法将browse这几个字改为 “请立即上传文件” ?

阅读 2.6k
3 个回答
    <input type="button" name="" value="请立即上传文件"><input type="file" name="files">

    input[type="file"]{
        opacity: 0;
        position: relative;
        top:0;
        left:-120px;
    }
    input[type="button"]{
        width:120px;
        height: 35px;
        line-height: 35px;
        background-color: #fff;
        font-size:14px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
    }

用一个按钮或者a标签或者div把其包裹起来,通过定位使其位置重合,然后将flie的原样式设置为透明度为0(opacity:0)

不可以更改,只能使用INPUT BUTTON组模拟。

你需要的是label这个标签

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题