【发布时间】:2015-05-23 23:44:05
【问题描述】:
我有一个输入字段:
<input type="file" name="fileToUpload" id="fileToUpload">
现在我想这样设计这个字段:
我该怎么做?
【问题讨论】:
我有一个输入字段:
<input type="file" name="fileToUpload" id="fileToUpload">
现在我想这样设计这个字段:
我该怎么做?
【问题讨论】:
这是html:
<span class="filewrap">
Some funny german words I don't understand
<input type="file"/>
</span>
这是 CSS:
.filewrap{
position:relative;
background:#000;
border:1px solid #cc0000;
padding:15px 100px;
color:#fff;
font-family:sans-serif;
font-size:12px;
}
input[type="file"]{
width:100%;
height:100%;
position:absolute;
top:0;
left:0;
opacity:0;
cursor:pointer;
}
【讨论】:
这样做的方法是在输入按钮的顶部放置一个元素并对其进行排序,以便上传输入在下方并因此隐藏。
HTML
<div class="fileUpload btn btn-primary">
<span>Upload</span>
<input type="file" class="upload" />
</div>
CSS
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
font-size: 20px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
一些更有用的链接:
【讨论】: