效果图
使用说明
复制代码,保存为 html 格式后,直接用浏览器打开即可。
代码
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>自定义 input file 样式及 js 上传图片本地预览</title>
<!-- 图标字体库 -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style type="text/css">
.file {
position: relative;
display: inline-block;
height: 30px;
line-height: 30px;
padding: 0 10px;
background-color: #009688;
color: #fff;
white-space: nowrap;
text-align: center;
font-size: 15px;
border: none;
border-radius: 2px;
cursor: pointer