<script>
function clp(){
return $("#File").click()
}
</script>
<button class = "clp" onclick = "clp()">clp</button>
<input type="file" id="File" style="display: none"/>
直接写CSS样式
是不行的
<input
type="text"
size="20"
name="upfile"
id="upfile"
style="border:1px
dotted
#ccc">
<input
type="button"
value="浏览"
onclick="path.click()"
style="border:1px
solid
#cccbackground:#fff">
<input
type="file"
id="path"
style="display:none"
onchange="upfile.value=this.value">
写成这样,用一个text和一个button替代file,然后让file隐藏
这个样式挺漂亮的,你可以试下:<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<title>定义input type="file" 的样式</title>
<style type="text/css">
body{ font-size:14px}
input{ vertical-align:middlemargin:0padding:0}
.file-box{ position:relativewidth:340px}
.txt{ height:22pxborder:1px solid #cdcdcdwidth:180px}
.btn{ background-color:#FFFborder:1px solid #CDCDCDheight:24pxwidth:70px}
.file{ position:absolutetop:0right:80pxheight:24pxfilter:alpha(opacity:0)opacity: 0width:260px }
</style>
</head>
<body>
<div class="file-box">
<form action="" method="post" enctype="multipart/form-data">
<input type='text' name='textfield' id='textfield' class='txt' />
<input type='button' class='btn' value='浏览...' />
<input type="file" name="fileField" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />
<input type="submit" name="submit" class="btn" value="上传" />
</form>
</div>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)