原生input file选择文件样式美化成按钮
外加一个a标签,内部的inout直接设置input透明度0,这样input也能点击;
如图为两种情况不同写法的效果截图
<a href="javascript:;" class="file">自定义上传
<input type="file" name="" id="">
</a>
样式:
<style> .file { position: relative; display: inline-block; background: #D0EEFF; border: 1px solid #99D3F5; border-radius: 4px; padding: 4px 12px; overflow: hidden; color: #1E88C7; text-decoration: none; text-indent: 0; line-height: 20px; } .file input { position: absolute; font-size: 100px; right: 0; top: 0; opacity: 0; cursor: pointer; } .file:hover { background: #AADFFD; border-color: #78C3F3; color: #004974; text-decoration: none; } </style>
本文来自博客园,作者:小虾米吖~,转载请注明原文链接:https://www.cnblogs.com/LindaBlog/p/17275256.html