【问题标题】:width and height functions not working in this宽度和高度函数在此不起作用
【发布时间】:2014-12-20 15:25:24
【问题描述】:

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

【问题讨论】:

标签: html css


【解决方案1】:

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

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

【讨论】:

  • 对不起,还有一个问题:当我将鼠标光标放在按钮上时,它不会显示手形光标,它通常会转到按钮上,而只是保持正常光标。你知道我该如何解决这个问题吗?
【解决方案2】:

默认情况下&lt;lablel&gt; 具有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;
  
}
<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-03
    • 2013-10-26
    • 2018-03-03
    • 2019-03-08
    • 1970-01-01
    • 2018-10-08
    • 2020-10-18
    相关资源
    最近更新 更多