日期:2014-05-17  浏览次数:20704 次

用CSS简单实现的点按钮选择文件的小例子
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
<!--
a.input_file_container{
	display:block;
	float: left;
	overflow: hidden;
	position:relative;
	width: 55px;
	height: 20px;
	border: 1px solid black;
	font-size: 10pt;
	line-height: 20px;
	text-align:center;
	color: black;
	text-decoration: none;
}
a.input_file_container:hover{
	background-color: #ECFFEE;
	border: 1px solid #268C00;
}
.input_file{
	width:75px;
	position: absolute;
	cursor: pointer;
	left: -5px;
	filter:alpha(opacity=1); /* IE */
	-moz-opacity:0.01; /* Moz + FF */
	opacity: 0.01; /* 支持CSS3的浏览器(FF 1.5也支持)*/ 
}
-->
</style>
</HEAD>
<BODY>
<form action='http://g.cn'>
	<a href='####' id="inputFileContainer" class="input_file_container">
		<input type=file id='file1' name='file1' class='input_file' onchange='this.form.submit()' hidefocus="true" />
		浏览 ...
	</a>
</form>
</BODY>
</HTML>