看过网上很多修改input file 文件上传的例子,真的非常麻烦,不仅css写一大堆,还要写一些js代码,或者是引入bootstrasp的样式。
其实只要用到html中label标签的for属性就可以达到修改input file的功能。
代码如下:
<label for="file_load" style="display:block;background: #1CB541;color:white;width: 100px;height: 35px;line-height: 35px;font-size: 14px;text-align: center;">更换头像</label>
<input id="file_load" type="file" style="display:none">