自定义文件上传按钮

<div class="new-contentarea"> 
  <a href="javascript:void(0)" class="btn-upload-img">选择图片</a>
  <input type="file" class="" name="upload-file" id="upload-file"/>
</div>

  

.new-contentarea{
	width: 165px;
	overflow:hidden;
	margin: 0 auto;
	position:relative;
	display: inline;
}
.btn-upload-img{
  	background-color: #f3fbff;
    border: 1px solid #bfe2fa;
    border-radius: 5px;
    color: #148ed5;
    display: inline-block;
    font-size: 14px;
    line-height: 36px;
    text-align: center;
    padding: 0 10px;
}
.new-contentarea input[type=file]{
	background: #333 none repeat scroll 0 0;
	height: 36px;
	left: 0;
	margin: 0;
	opacity: 0;
	position: absolute;
	top: -7px;
	width: 77px;
	z-index: 2;

  

参考文档:https://blog.csdn.net/ld_____/article/details/48680159

posted @ 2018-08-14 15:06  zph前端  阅读(318)  评论(0编辑  收藏  举报