I have an input field:
<input type="file" name="fileToUpload" id="fileToUpload">
Now i want to design this field like this:
How can i do this?
I have an input field:
<input type="file" name="fileToUpload" id="fileToUpload">
Now i want to design this field like this:
How can i do this?
Here's the html:
<span class="filewrap">
Some funny german words I don't understand
<input type="file"/>
</span>
and here's the 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;
}
See this demo fiddle
The way to do this is to place an element on top of the input button and order them so that the upload input is underneath and therefore hidden.
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);
}
Some more useful links: