我正在使用不透明方法的樣式輸入文件 - 實際輸入文件按鈕具有不透明度0,並且在它之前,使用z-index是另一個輸入(不透明度:1)。不幸的是,我希望我的可見按鈕是平方的圖片(寬:高:1:1) - 並且不可見的輸入文件始終是矩形(輸入框和選擇框的縱橫比約爲1:10)。問題是 - 如何調整輸入文件按鈕的平方(或任何大小),以使整個可見按鈕區域可點擊(因爲只有點擊不可見按鈕會導致打開瀏覽器窗口)。現在只有可見按鈕的一部分是「可點擊」的。如何更改輸入文件按鈕大小?
CSS:
<style type="text/css">
.upload {
position:relative;
width:100px;
}
.realupload {
position:absolute;
top:0;
right:0;
opacity:0.5;
-moz-opacity:0.5;
filter:alpha(opacity:0.5);
z-index:2;
width:100px;
}
form .fakeupload {
background: url(images/bglines.png);
}
form .fakeupload input {
width:0px;
}
</style>
和HTML:使用 「圖像」 輸入型
<form>
<li class="upload">
<div class="fakeupload">
<input type="text" name="fakeupload" style="opacity: 0;"/>
</div>
<input type="file" name="upload" id="realupload" class="realupload" onchange="this.form.fakeupload.value = this.value;" style="font-size: 5px;" />
</li>
</form>
爲什麼要將文本輸入字段頂部的文件輸入字段?這可能是你的問題完全。 – Scott 2012-02-05 22:00:08
改變輸入的位置沒有區別:( – Kalreg 2012-02-05 22:12:14