I am building a BlogApp and I am trying to customize the FileUpload
button.
What i am trying to do
I am trying to customize the File Upload
button using CSS
button , I am unable to access it with my model instance
( {{ form.file}} )
CSS
.btn-upload {
position: relative;
overflow: hidden;
display: inline-block;
}
.btn-upload input[type=file] {
position: absolute;
opacity: 0;
z-index: 0;
max-width: 100%;
height: 100%;
display: block;
}
.btn-upload .btn{
padding: 8px 20px;
background: #337ab7;
border: 1px solid #2e6da4;
color: #fff;
border: 0;
}
.btn-upload:hover .btn{
padding: 8px 20px;
background: #2e6da4;
color: #fff;
border: 0;
}
HTML
#This is my image form field in template
{{ form.file }}
What have i tried
- I tried using this
<input type="file" name="file" class="btn-upload">
BUT it didn't worked for me.
Any help would be really Appreciated.
Thank You in Advance.
I tried many time by adding classes
and ids
but none of them worked for me.
I don't how can i