效果:
html 代码:
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="test.css">
</head>
<body>
<div>
<form class="box">
<span>+</span>
<div id="=preview" class="preview"></div>
<input type="file" class="input-file">
</form>
</div>
</body>
</html>
css 代码:
.box{
position: relative;;
width: 100px;
height: 100px;
background-color: #ccc;
border: 1px solid green;
text-align: center;
line-height: 100px
}
.preview{
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
.input-file{
position: absolute;
opacity: 0;
cursor: pointer;
width: 100%;
height: 100%;
top: 0;
left: 0;
}