---
title: "一个改变input：file样式的小技巧"
author: "fftiger"
date: "2015-05-24T22:18:50Z"
tags: []
categories: ["Web前端"]
slug: "input-file"
draft: false
lastmod: "2015-05-24T22:18:50Z"
id: 2213876
url: "https://fftiger.iteye.com/blog/2213876"
---

:D 相信大家对<input type="file"/>标签的样式都不感冒吧，尤其是文字很难自己设置，下面就是一个改变样式的小技巧，目前没发现不兼容的浏览器的：

<input id="upfile" type="file" name="file" style="display:none" />
<button onclick="document.getElementById('upfile').click()">上传文件</button>

你可以随便改变button的样式，达到自己想要的。