我已经制作了一个文件上传表单,并试图在css中更改它的大小。我可以改变颜色,但高度和宽度不会改变
HTML:
<form action="gogogo.php" method="post" enctype="multipart/form-data">
<label class="filebutton">
Upload
<span><input type="file" id="myfile" name="myfile" onchange="this.form.submit();"></span>
</label>
CSS:
label.filebutton {
width:300px;
height: 100px;
overflow:hidden;
position:relative;
background-color:#FF9933;
}
label span input {
z-index: 999;
line-height: 0;
font-size: 50px;
position: absolute;
top: -2px;
left: -700px;
opacity: 0;
filter: alpha(opacity = 0);
-ms-filter: "alpha(opacity=0)";
cursor: pointer;
_cursor: hand;
margin: 0;
padding:0;
width: 50px;
}
答案 0 :(得分:1)
将display:block;
或display:inline-block;
添加到css label.filebutton
答案 1 :(得分:0)
默认<lablel>
有display:inline
。内联对象没有高度或宽度。
因此设置display:block;
或display:inline-block;
label.filebutton {
display: block;
width: 250px;
height: 100px;
overflow: hidden;
position: relative;
background-color: #FF9933;
}
label span input {
z-index: 999;
line-height: 0;
font-size: 50px;
position: absolute;
top: -2px;
left: -700px;
opacity: 0;
filter: alpha(opacity=0);
-ms-filter: "alpha(opacity=0)";
cursor: pointer;
_cursor: hand;
margin: 0;
padding: 0;
}
&#13;
<form action="gogogo.php" method="post" enctype="multipart/form-data">
<label class="filebutton">
Upload
<span><input type="file" id="myfile" name="myfile" onchange="this.form.submit();"/></span>
</label>
&#13;