宽度和高度功能不起作用

时间:2014-12-20 05:47:11

标签: html css

我已经制作了一个文件上传表单,并试图在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;
}

2 个答案:

答案 0 :(得分:1)

display:block;display:inline-block;添加到css label.filebutton

工作演示http://jsfiddle.net/ho21b4Lf/

答案 1 :(得分:0)

默认<lablel>display:inline。内联对象没有高度或宽度。

因此设置display:block;display:inline-block;

&#13;
&#13;
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;
&#13;
&#13;