如何将input type=file显示的浏览为自定义
2016-08-10 · 百度知道合伙人官方认证企业
将input type=file显示的浏览为自定义的方法是:
1、定义一个装载file的form:
<label for="upload-photo">Browse...</label>
<input type="file" name="photo" id="upload-photo" />
2、自定义css样式:
label {
pointer: cursor;
/* Style as you please, it will become the visible UI component. */
}
#upload-photo {
opacity: 0;
position: absolute;
z-index: -1;
}
3、完整代码及结果如下:
<!DOCTYPE html>
<html>
<head>
<style>
label {
pointer: cursor;
/* Style as you please, it will become the visible UI component. */
}
#upload-photo {
opacity: 0;
position: absolute;
z-index: -1;
}
</style>
</head>
<body>
<label for="upload-photo">Browse...</label>
<input type="file" name="photo" id="upload-photo" />
</body>
</html>