在複習html5,file時,偶然找到了一篇之前一直想實現的樣式需求。貼代碼如下,但還有兩個問題不太懂。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>上傳文件</title>
</head>
<style type="text/css">
.fileInputContainer{
height:256px;
background:url(http://images.cnblogs.com/cnblogs_com/dreamback/437546/o_ff6.png);
position:relative;
width: 256px;
}
.fileInput{
height:256px;
overflow: hidden;
/*不太理解爲什麼要這樣設置???*/
font-size: 300px;
position:absolute;
/*opacity=1時,爲什麼文字會消失?*/
right:0;
top:0;
opacity: 0;
filter:alpha(opacity=0);
cursor:pointer;
}
</style>
<body>
<div class="fileInputContainer">
<input class="fileInput" type="file" name="" id="" />
</div>
</body>
</html>
在chrome下結果
存在的問題:選擇文件後,無法看到是否已經選擇文件。
原文地址:http://www.cnblogs.com/dreamback/archive/2012/12/25/input-file-css-beautify.html